I wanted to use a native Dll in my C# .net application as this:
public const int WFSDDESCRIPTION_LEN = 256;
public const int WFSDSYSSTATUS_LEN = 256;
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Auto)]
public struct LPWFSVERSION
{
[MarshalAs(UnmanagedType.U4, SizeConst = 4)]
int WVersion;
[MarshalAs(UnmanagedType.U4, SizeConst = 4)]
int WLowVersion;
[MarshalAs(UnmanagedType.U4, SizeConst = 4)]
uint WHighVerion;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = WFSDDESCRIPTION_LEN + 1)]
public string szDescription;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = WFSDSYSSTATUS_LEN + 1)]
public strin开发者_开发技巧g szSystemStatus;
}
[DllImport("MSXFS.DLL", EntryPoint = "WFSStartUP", CharSet = CharSet.Auto, ExactSpelling = false)]
public static extern int WFSStartUP([MarshalAs(UnmanagedType.U4)]int dwVersionsRequired, ref LPWFSVERSION ver);
and here the code where I've used the imported function:
LPWFSVERSION Ver = new LPWFSVERSION();
WFSStartUP(0x31, ref Ver);
the problem is that it throws an exception which says:"Unable to find an entry point"
I have dump the msxfs.dll with dumpbin and the result was this:
Section contains the following exports for MSXFS.d
00000000 characteristics
46938FBD time date stamp Tue Jul 10 17:25:09 200
0.00 version
1 ordinal base
37 number of functions
37 number of names
ordinal hint RVA name
1 0 00009310 WFMAllocateBuffer
2 1 000093D0 WFMAllocateMore
.
.
32 1F 00005BD0 WFSOpen
33 20 00007C80 WFSRegister
34 21 00008CD0 WFSSetBlockingHook
35 22 00004FA0 WFSStartUp
It seems to be there was no problem in dll side as the dumpbin could find entry point as well. I don't know what the problem is? :(
35 22 00004FA0 WFSStartUp
That's Up, not UP.
精彩评论