473,395 Members | 2,689 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

VB2005 Short address pointer

A call to a third party dll, which will call back, requires an hWnd and a 16
bit sub address. Yes this was designed for VB6.

Addressof and delegates and all that good crap doesn't help.

The hWnd where the subroutine is located is no problem. But how can I
provide the subroutines address as a Short ??

GalenS


May 2 '06 #1
2 1603
>A call to a third party dll, which will call back, requires an hWnd and a 16
bit sub address. Yes this was designed for VB6.
VB6 also targets Win32 so I don't see how it could work there.

The hWnd where the subroutine is located is no problem. But how can I
provide the subroutines address as a Short ??


If you're running .NET 2.0 you can try calling
Marshal.GetFunctionPointerForDelegate(), truncate the result to
16-bits and see if it works.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
May 2 '06 #2

"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:OP**************@TK2MSFTNGP02.phx.gbl...
A call to a third party dll, which will call back, requires an hWnd and a
16
bit sub address. Yes this was designed for VB6.


VB6 also targets Win32 so I don't see how it could work there.

The hWnd where the subroutine is located is no problem. But how can I
provide the subroutines address as a Short ??


If you're running .NET 2.0 you can try calling
Marshal.GetFunctionPointerForDelegate(), truncate the result to
16-bits and see if it works.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.


My bad. In VB2005 it would be integer not short

VB6 code in bas module. The Call SetEventTable is immediately followed by
the 3rd party dll call WDU_Init

Dim eventTable As WDU_EVENT_TABLE

Call SetEventTable(eventTable, AddressOf DeviceAttach, AddressOf
DeviceDetach)
eventTable.pUserData = WD_VB_GetAddress(DevCtx, 1, 1)

dwError = WDU_Init(hdriver, matchTable, 1, eventTable, _
DEFAULT_LICENSE_STRING, WD_ACKNOWLEDGE, hWnd)

VB6 driver code bas module. It would appear that the AddressOf's could be
left out of the SetEventTable call and placed directly after the ='s below.

Public Sub SetEventTable(ByRef eventTable As WDU_EVENT_TABLE, ByVal attachCb
As Long, _
ByVal detachCb As Long)
eventTable.pfDeviceAttach = attachCb
eventTable.pfDeviceDetach = detachCb
End Sub

Public Type WDU_EVENT_TABLE
pfDeviceAttach As Long
pfDeviceDetach As Long
pfPowerChange As Long
pUserData As Long
End Type
VB6 declares for callback procedures

Public Function DeviceAttach(ByVal hDevice As Long, ByRef pDeviceInfo As
WDU_DEVICE, _
ByRef pUserData As DEVICE_CONTEXT) As Boolean
Public Sub DeviceDetach(ByVal hDevice As Long, ByRef pUserData As
DEVICE_CONTEXT)

GalenS
May 2 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

99
by: Glen Herrmannsfeldt | last post by:
I was compiling a program written by someone else about six years ago, and widely distributed at the time. It also includes makefiles for many different systems, so I know it has been compiled...
9
by: Igor Okulist | last post by:
int func(void**); { short* p = NULL; func(&p); //<<< here } Could somebody remind me why is this not allowed ? error message: "cannot convert parameter from 'short **' to 'void **'"
8
by: t | last post by:
In VB6, I usually use objptr function and API copymemory to identify and obtain an object, how can I convert them into VB2005? Your kindly help would be much appreciated.
10
by: Galen Somerville | last post by:
Going from VB6 (RAD) to VB2005 (SAD) The documentation always shows graphics drawing in a paint event like Private Sub Pictcolor_Paint(ByVal sender As Object, ByVal e _ As...
92
by: =?Utf-8?B?bW9iaWxlbW9iaWxl?= | last post by:
I'm trying to load this structure for a call to DeviceIoControl: typedef struct _NDISUIO_QUERY_OID { NDIS_OID Oid; PTCHAR ptcDeviceName; UCHAR Data; } NDISUIO_QUERY_OID, *PNDISUIO_QUERY_OID; ...
15
by: Aalaan | last post by:
I am presently a user of classic vb6 and hang out on those newsgroups. Some of you may be aware that there is a very anti MS and vb2005 feeling there. I have tried to get them to tell me which...
2
by: CptDondo | last post by:
I'm trying to write what should be a simple program, and it keeps hanging if I use volatile.... The program, stripped of its error checking, is this: unsigned short * start; unsigned short *...
3
by: =?Utf-8?B?QmVu?= | last post by:
Hi all, I am new to vb2005. I have two list boxes on a form. one on the left and the other on the right. The left contains a list of items. Between the two list boxes I have a button to add...
17
by: spasmous | last post by:
I need a way to search through a block of memory for a char array "DA" using a pointer to a short. Ideally I would like to write something like: short *data = ... some data...; int j = 0;...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.