i have this function in c++ which defined in header file
MYDLL_API BOOL GetFolderSize(LPCTSTR lpszStartFolder,
BOOL bRecurse,
BOOL bQuickSize,
PLARGE_INTEGER lpFolderSize,
LPDWORD lpFolderCount ,
LPDWORD lpFileCount );
where MYDLL_API is defined as
#ifdef MYDLL_EXPORTS
#define MYDLL_API __declspec(dllexport)
#else
#define MYDLL_API __declspec(dllimport)
#endif
after compile it as DLL project
i create c# declaration for this function as this
[StructLayout(LayoutKind.Explicit, Size = 8)]
struct LARGE_INTEGER
{
[FieldOffset(0)]
public Int64 QuadPart;
[FieldOffset(0)]
public UInt32 LowPart;
[FieldOffset(4)]
public Int32 HighPart;
}
[DllImport("mydll.dll")]
extern static bool GetFolderSize(string lpszStartFolder,
bool bRecurse,
bool bQuickSize,
out LARGE_INTEGER lpFolderSize,
out UInt32 lpFolderCount,
out UInt32 lpFileCount);
in run time it did not give an exception but it return false (mean that the function is failed )
why ? is the reason because of complicated data type in c++ (PLARGE_INTEGER)
or what ??
thanks
What I have tried:
i have try this
[StructLayout(LayoutKind.Explicit, Size = 8)]
struct LARGE_INTEGER
{
[FieldOffset(0)]
public Int64 QuadPart;
[FieldOffset(0)]
public UInt32 LowPart;
[FieldOffset(4)]
public Int32 HighPart;
}
[DllImport("mydll.dll")]
extern static bool GetFolderSize(string lpszStartFolder,
bool bRecurse,
bool bQuickSize,
out LARGE_INTEGER lpFolderSize,
out UInt32 lpFolderCount,
out UInt32 lpFileCount);