|
Re: .Net Question, How to reference a dll with different names
02/28/07 05:22 PM
|
|
|
better late than never I guess...
here are some clues as to how to do what you want.
public delegate Int32 WSAStartupDelegate( UInt16 wVersionRequired, byte[] lpWSAData ); public static WSAStartupDelegate WSAStartup;
public class Win32 { [DllImport( "ws2_32.dll" )] public static extern Int32 WSAStartup( UInt16 wVersionRequired, byte[] lpWSAData ); }
public class WinCE { [DllImport( "ws2.dll" )] public static extern Int32 WSAStartup( UInt16 wVersionRequired, byte[] lpWSAData ); }
then do either:
WSAStartup = WinCE.WSAStartup;
or
WSAStartup = Win32.WSAStartup;
depending on which one you want. Then do WSAStartup() and it will call the relevant code.
or you can just decide whether to call WinCE.WSAStartup() or Win32.WSAStartup() at runtime. I find it better to not polute the code, but it's up to you.
Without the classes, this is how to have the same function in different dll's.
[DllImport("coredll.dll", EntryPoint="PeekMessage", SetLastError=true)] private static extern bool PeekMessageCE(out MSG lpMsg, IntPtr hWnd, uint wMsgFilterMin, uint wMsgFilterMax, uint wRemoveMsg);
[DllImport("User32.dll", CharSet=CharSet.Auto, EntryPoint="PeekMessage")] private static extern bool PeekMessageDT(out MSG msg, IntPtr hWnd, uint messageFilterMin, uint messageFilterMax, uint flags);
You then call either PeekMessageCE or PeekMessageDT.
smf
Edited by smf (02/28/07 05:23 PM)
|
|