Hello all,
I'm trying to upgrade a VB6 project into VB.net, and the problem I had is in converting 'address of' to 'delegate'.
I had the error "Value of type 'DelegateIDccManSink_OnLogIpAddr' cannot be converted to 'integer'.",
when calling this line, ReplaceVtableEntry(.., .., callbackOnLogIpAddr).
I guess the problem is due to the VB6 expected a memory address, but the 'delegate' doesn't return an address.
Any ideas are appreciated. - Public Delegate Function DelegateIDccManSink_OnLogIpAddr(ByVal this As KwyDccMan.IDccManSink, ByVal dwIpAddr As Integer) As Integer
-
-
-
Public Sub DccManSinkInitialize(ByVal this As KwyDccMan.IDccManSink)
-
-
Dim lObjAddress As Integer
-
Dim callbackOnLogIpAddr As DelegateIDccManSink_OnLogIpAddr
-
-
' Object Address
-
lObjAddress = ObjPtr(this)
-
-
callbackOnLogIpAddr = New DelegateIDccManSink_OnLogIpAddr(AddressOf IDccManSink_OnLogIpAddr)
-
-
' Replace VTable Function Entries
-
-
m_lFnOnLogIpAddr = ReplaceVtableEntry(lObjAddress, &H4S, callbackOnLogIpAddr)
-
-
End Sub
-
-
Private Function IDccManSink_OnLogIpAddr(ByVal this As KwyDccMan.IDccManSink, ByVal dwIpAddr As Integer) As Integer
-
IDccManSink_OnLogIpAddr = SCDCallParams(ObjPtr(this), EDccManCallID.eCallIDSink_OnLogIpAddr, dwIpAddr)
-
End Function
-
-
' Put the function address (callback) directly into the object v-table
-
Public Function ReplaceVtableEntry(ByVal lpObj As Integer, ByVal nEntry As Short, ByVal lpFunc As Integer) As Integer
-
' lpObj - Pointer to object whose v-table will be modified
-
' nEntry - Index of v-table entry to be modified
-
' lpFunc - Function pointer of new v-table method
-
-
Dim lpFuncOld As Integer, lpVTableHead As Integer, lpFuncTmp As Integer, nOldProtect As Integer
-
-
' Object pointer contains a pointer to v-table--copy it to temporary
-
CopyMemory(lpVTableHead, lpObj, 4)
-
' Calculate pointer to specified entry
-
lpFuncTmp = lpVTableHead + (nEntry - 1) * 4
-
-
' Save address of previous method for return
-
CopyMemory(lpFuncOld, lpFuncTmp, 4)
-
-
' Ignore if they're already the same
-
If lpFuncOld <> lpFunc Then
-
' Need to change page protection to write to code
-
VirtualProtect(lpFuncTmp, 4&, PAGE_EXECUTE_READWRITE, nOldProtect)
-
-
' Write the new function address into the v-table
-
CopyMemory(lpFuncTmp, lpFunc, 4) ' *lpFuncTmp = lpFunc;
-
-
' Restore the previous page protection
-
VirtualProtect(lpFuncTmp, 4, nOldProtect, nOldProtect) 'Optional
-
End If
-
-
ReplaceVtableEntry = lpFuncOld
-
-
End Function
0 1366 Sign in to post your reply or Sign up for a free account.
Similar topics |
by: john |
last post by:
Hello,
I am trying to convert a project from vb6 to vb.net. The code is a
sample from an sdk for Canon digital camera's. I have gotten most of the
issues resolved, but there are some that I am...
|
by: BoloBaby |
last post by:
OK, here's the problem...
I have a digital input/output card that exposes IRQs (digital input
change-of-state) through a DLL function.
In VB6.0, I can use this ability through code that looks...
|
by: BoloBaby |
last post by:
OK, I've managed to clarify my question (whew).
I'll show two blocks of code - one in VB6.0 and one in VB.NET. The VB6.0
code manages to execute the callback function, the VB.NET does not. The...
|
by: Michael Turner |
last post by:
Hi guys I am having the following problem upgrading a vb6 application, I
have click the link as it suggested and I have search the net only to become
even more confussed! HELP!!!
Error: - ...
|
by: damianmatiasmax |
last post by:
Helow, Good days.
I am creating a class Base in VB.NET, then I use this class base to
create to the class son across inherits, and Then generate the object
COM this class son to be used in VB6....
| |
by: Terry |
last post by:
I am converting (attempting) some vb6 code that makes vast use of interfaces.
One of the major uses is to be able to split out Read-only access to an
obect. Let me give you a simple (contrived)...
|
by: redeagle |
last post by:
In VB6, the code for a structure is
Structure zFuheader
Dim Id1(80) As Byte
Dim Id2(80) As Byte
End Structure
However, in .NET, it doesn't let you declare the array size in the
structure.
|
by: Dhananjay |
last post by:
Hi All,
I am facing problem when i am converting C#.net code(Delegate concept)
into vb.net. I am unable to do that . Can someone help me to solve the
problem. I am providing my C#.net code.
...
|
by: =?Utf-8?B?TWlrZSBN?= |
last post by:
Hi,
My conversion seems from VB6 to VB.Net of an interface to an API seem to
have gone OK, but when I look at the output from the Debug.Print("Active
server is " & xmlServerActive) statement,...
|
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...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
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...
|
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: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |