Solved

VB and pointers et al

Posted on 2003-11-06
7
337 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…

752 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