Dll Calls: Need Help Learning How To. 
Author Message
 Dll Calls: Need Help Learning How To.

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://www.*-*-*.com/
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



Mon, 06 Jun 2005 22:44:58 GMT  
 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



Tue, 07 Jun 2005 01:59:51 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. HELP: Need help with wininet.dll calls!

2. Help Help Help i need to learn how to do fades in qbasic 4.5

3. Need help calling a DLL!

4. Need help/ calling external DLL from VB6

5. Need Help w/ comdlg32.dll Call in VB4

6. Need help/calling external DLLs from VB6

7. newbie needs help with calling a DLL

8. Need HELP with Delphi DLL to be Called by VB 5.0

9. NEED help Calling a VC++ DLL from VB4

10. Calling a win32 DLL in a vb app - Need help

11. Help needed POSTing to SSL server using wininet.dll API calls

 

 
Powered by phpBB® Forum Software