Solved

VB and pointers et al

Posted on 2003-11-06
7
317 Views
Last Modified: 2010-07-27
This is something that's probably been covered time and time again.  I'm working with external DLLs that require pointers to byte array and also pointers to the equivalent of a DWORD.

I think I understand the pointer to a byte array, using the concept of ByRef and myArray(0) to pass to a DLL or return from a DLL, but what about a DWORD, how can I pass a pointer to my variable in VB and either pass my number to the DLL or get it to pass a response back into my variable?

If that makes any sense, I'll be very surprised.

Thanks
Simon
0
Comment
Question by:sbennetts
  • 4
  • 3
7 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 125 total points
ID: 9693665
If C++ function has DWORD parameter, use ByValue Integer in VB.
If C++ function has DWORD* parameter, use ByRef Integer in VB.
0
 
LVL 2

Author Comment

by:sbennetts
ID: 9693842
Is there a definitive list for this kind of thing?  It's something I always spend ages and ages on...
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 9693985
I usually find some API with parameters of required type and see how API viewer generated API declaration. For example, to see difference between DWORD and DWORD* you can compare GetComputerName and GetWindowText.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 2

Author Comment

by:sbennetts
ID: 9694091
...but how does that tell you about the actual function call in the DLLs?
0
 
LVL 2

Author Comment

by:sbennetts
ID: 9694133
i.e. what they are expecting in...
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 9694384
Compare GetComputerName and GetWindowText API declarations in MSDN and generate their VB declarations using API Viewer. When Dll function has DWORD* parameter, you pass ByRef Integer. Dll gets DWORD* and may change this variable.
0
 
LVL 2

Author Comment

by:sbennetts
ID: 9701362
Many thanks
Simon
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now