Solved

VB and pointers et al

Posted on 2003-11-06
7
323 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

773 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