i'm trying to use 3ivx to transcode and mpeg2 file, here is one of their com objects methods that i'm trying to use, but it doesn't like the .net type marshaling.
HRESULT GetPropString( char *pcName, unsigned int *puiSize, char *pcValue );
pcName: [in] Name of desired property, C-string.
puiSize: [in/out] Pointer to an Unsigned Int containing the size of the buffer, afterwards it contains the size of the string
pcValue: [out] Pointer to a Char buffer to receive a copy of the C-String property specified, if NULL then the String is not copied,
but puiSize is updated.
converted to
int SetPropString(
[MarshalAs(UnmanagedType.LPStr)]string pcName,
[In,Out]IntPtr piValue,
[Out, MarshalAs(UnmanagedType.LPStr)]out string sb);
i call this using:
IntPtr ptr = Marshal.AllocCoTaskMem(sizeof(int));
SetPropString("some string", ptr, "");
doesnt work, any ideas?
-
-
Instead of 'out string sb', try using 'StringBuilder sb'.
-
Don't you have a type library or something to generate the interop wrapper with (using tlbimp)? Because this signature is all wrong. As Tommy said you should use a stringbuilder. You can also use a ref int for the second parameter, and the return value should be void, since COM Interop automatically translates HRESULTs into exceptions unless you specify [PreserveSig()].
Also, should it be GetPropString or SetPropString?
The proper signature would be:
void GetPropString([MarshalAs(UnmanagedType.LPStr)] string pcName, ref int puiSize, [MarshalAs(UnmanagedType.LPStr)]StringBuilder pcValue);
You call it like this:
int size = 100; // or whatever size you like;
StringBuilder value = new StringBuilder(100);
comObj.GetPropString("some string", ref size, value); -
sorry my bad, it should be GetPropString. it still does not work, i think there is a problem with the com, because there are 2 other methods GetPropInt and ResetProps, they both work fine.
i don't have a type library, only have the header files.
another small question, for an unsigned char * what .net equivalent can i use? byte[] ?
Thread Closed
This thread is kinda stale and has been closed but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.