tags:

views:

21

answers:

1

What should be the C# signiture for this function? (for pInvoke)

DWORD GetVatAccount(COleDateTime dtDateTime, BSTR FAR* strResult)
+1  A: 
[DllImport("test.dll")]
private static extern int GetVatAccount(
    double dtDateTime, 
    StringBuilder strResult
);

or:

[DllImport("test.dll")]
private static extern int GetVatAccount(
    double dtDateTime, 
    [MarshalAs(UnmanagedType.BStr)]ref string strResult
);

The conversions between the dates and double could be done with DateTime.FromOADate and DateTime.ToOADate methods.

Darin Dimitrov
does the return type to be int or uint? to work in all windows OS.and what about the BSTR FAR * thing?
Elias Haileselassie
Both should work, but indeed `uint` looks more appropriate.
Darin Dimitrov