What is the equivalence of LPCTSTR * in C #

I have an unmanaged C ++ function inside a Dll that I call from my C # application. Here is the function signature:

GetCrashMeasurement(LPCTSTR channelName, LPCTSTR properties, LPCTSTR * Values, HANDLE error)

where channelNameand propertiesis the input parameter [in]; and Values- output parameter [out].

I also use the invoke platform from my C # application as follows:

[DllImport("DrvCrashHAL.dll", EntryPoint = "coCRAL_GetCrashMeasurements")]

public static unsafe extern CoStatus GetCrashMeasurements(string sChannel, string sMeasurements, ref string sValues, IntPtr hError);

From my C # application, I call the function as follows:

string Text = "";
intptr herror = intptr.zero;
GetCrashMeasurements("channelname","",ref Text,herror);

But then my program stops exactly on this line, without throwing any exception, and all I see in the output window is the following message:

Critical error detected c0000374
Critical error detected c0000374
The program '[4964] ProjectX.exe: Managed' has exited with code 0 (0x0).
The program '[4964] ProjectX.exe: Native' has exited with code 0 (0x0).

My guess is that the problem is with the sort type LPCTSTR.

Can someone tell me what I'm doing wrong or point me in the right direction?

Thanks in advance.

+4
2

, , 1, 2 4 . , , 3.

c0000374 - . .

- , . char**, [out] , char*. , , , , , .

int * int ** intptr. , (a) (b) ( int ). , . COM BSTR, .

, Interop, out string sValues, ref. , .

, : http://msdn.microsoft.com/en-us/magazine/cc164193.aspx.

. , , , .

+1

@jester LPCTSTR* Values, . ?

public static unsafe extern CoStatus GetCrashMeasurements(string sChannel, string sMeasurements, string[] sValues, IntPtr hError);

GetCrashMeasurements("channelname","",new[] { Text },herror);

MarshalAs sValues.

public static unsafe extern CoStatus GetCrashMeasurements(string sChannel,
                                                          string sMeasurements,
                                                          [MarshalAs(UnmanagedType.LPArray, ArraySubType=UnmanagedType.LPTStr)]
                                                          string[] sValues,
                                                          IntPtr hError);
0

Source: https://habr.com/ru/post/1533471/


All Articles