**************import the prototype of api**
Quote:
[DllImport ("kernel32.dll",EntryPoint="LoadLibraryW",
CharSet=CharSet.Unicode,CallingConvention=CallingC onvention.StdCall,
SetLastError =true)]
public extern static IntPtr LoadLibrary(String lpFileName);
Just FYI, you shouldn't specify the LoadLibraryW entry point unless you
specified ExactSpelling = true on the DllImport attribute. You're already
specifying to use the Unicode character set, as such that would be handled
automatically. Also, you don't need to specify the EntryPoint unless it's
different than the name of the function you're defining. Just some nice
things you might want to do to help simplify your code. :o)
For example: This would need it.
[DllImport("myfile.dll", EntryPoint = "Foo")]
public static extern void Bar();
After looking in both the WinBase.h and Windows.h header files the MSDN
documentation states they're located in there was only a single declaration
for the GetProcAddress function - which leads me to believe you are correct
when you said that only the ANSI version is available. Not to mention there
is no information in the MSDN documentation indicating there is both a
Unicode and ANSI version available.
Perhaps because old C didn't allow Unicode characters in their definitions.
I don't know, I'm completely guessing there. Never used it before so I
couldn't say either way for sure. That's the only reason I could think of
why there wouldn't be a unicode version of the definition.
"Ryanivanka" <sarah.hhyy@gmail.comwrote in message
news:%23BH0N5W4IHA.2332@TK2MSFTNGP03.phx.gbl...
Quote:
hi,Ben
>
the export of the DLL is right. I check them with a tool software.
>
>
and I change the prototype of getProcAddress(..) in C# as follows:
**************************
[DllImport("Kernel32.dll", EntryPoint = "GetProcAddress", CharSet =
CharSet.Ansi, CallingConvention = CallingConvention.StdCall , SetLastError
= true)]
public extern static IntPtr GetProcAddress(
IntPtr handle,
[MarshalAs(UnmanagedType.LPStr)]string funcname);
***************************
>
if I change it into unicode ,everything go wrong. I don't why ,maybe
GetProcAddress() only has ANSI version.
>
just put result here for someone may encounter the same problem.
>
>
>
>
>
"Ben Voigt [C++ MVP]" <rbv@nospam.nospam>
写入消息新闻:eCwjTSR4IHA.1420@TK2MSFTNGP06.phx.gbl ...
Quote:
Quote:
>>the getProcAddress(..) doesn't work.Where am i wrong?
>>
>Does the filename of the DLL you need to load change after compile time?
>If not, let p/invoke handle all the dynamic loading mess for you and just
>use DllImport and declare the function you need to call.
>>
>
>