Solved

VB and pointers et al

Posted on 2003-11-06
7
315 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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

746 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

13 Experts available now in Live!

Get 1:1 Help Now