
Dll Calls: Need Help Learning How To.
The way I understand it is that most C++ types are specialized versions of
simpler types. So LPCWSTR, LPSTR etc... can all be marshaled to a standard
String type in VB. This doesnt always work, so you need to do a little
research when you come across a type that you cant figure out how to
marshal. A good book is The Win32 API Puzzle book by Danny Appleman. It was
written for VB6, but it applies to .NET too. Danny has a seriously massive
ego, but once you get past that, he actually does have a vast knowledge of
the topic.
Good luck,
Jeremy
Quote:
> I need some help with calling dll's from vb.net.
> The dll I am using is netapi32.dll:NetServerEnum.
> I can find source code on how to do it but I want to know
> why it was done the way it was. What I am getting at is I
> want to learn how to read the SDK info from microsoft on
> the function and produce the dllimport statment and code
> to get the function to work.
> This is a link to the SDK info:
> http://msdn.microsoft.com/library/default.asp?
> url=/library/en-us/netmgmt/netmgmt/netserverenum.asp
> Take the first parameter, servername. It is a c++ type of
> LPCWSTR. The Description says it must be null. So I would
> create the dllimport parameter: ByVal ServerName as
> String, and pass vbnullstring as the value.
> Next Parameter, level. I would create the parameter as
> ByVal Level as integer and value of 100.
> Next Parameter, LPBYTE bufptr. If I understand this I
> create the parameter as stringbuilder and specify a size
> large enough to handle the return data.
> Is there a table or listing that shows what to pass when
> the c++ type is LPCWSTR, DWORD, LPBYTE, ...
> Any info will help. I know this post may not state clearly
> what I am asking, but that is how confused I am.
> Thanks in Advance
> Eric