 |
|
 |
eddom Level: Big Cheese
 Registered: 14-03-2006 Posts: 24
|
Met problem again with API
Structure in C++
int Initialization(int port, HWND hWnd, HINSTANCE hInst)
int SetValidGateway(char *data, int dataSize)
int GetValidGateways(char *data, int dataSize)
int GetConnectedGateways(char *data, int dataSize)
|
Souce Code
Declare Function Initialization Lib "Vertx.dll" (ByVal PortNum As Integer, ByVal HWND As IntPtr, ByVal HInst As Int32) As Integer
Declare Function SetValidGateways Lib "Vertx.dll" (ByVal Mac As String, ByVal DataSize As Integer) As Integer
Declare Function GetValidGateways Lib "Vertx.dll" (ByVal GetMac As String, ByRef DataSize As Integer) As Integer
Declare Function GetConnectedGateways Lib "Vertx.dll" (ByVal GetMac2 As String, ByRef DataSize2 As Integer) As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim PortNum As Integer = 4070
Dim HWND As IntPtr = Me.Handle
Dim HInst As Int32 = AppDomain.GetCurrentThreadId
Dim Mac As String = "00:0B:EB"
Dim GetMac As String
Dim GetMac2 As String
Dim DataSize As Integer = 256
Dim DataSize2 As Integer = 256
GetMac = Space(DataSize)
GetMac = Space(DataSize)
Initialization(PortNum, HWND, HInst)
SetValidGateways(Mac, 8)
GetValidGateways(GetMac, DataSize)
GetMac = GetMac.Substring(0, GetMac.IndexOf(Chr(0)))
GetConnectedGateways(GetMac2, DataSize2) <---- this line cause error
GetMac2 = GetMac2.Substring(0, GetMac2.IndexOf(Chr(0)))
TxtInput.Text = GetMac2
End Sub
|
Since that the sturcture for GetConnectedGateways and GetValidGateways are the same, why GetValidGateways can work well with the code, but GetConnectedGateways will cause error with the same method applied?? Anybody can spot the error? plz help, thanks
[Edited by eddom on 21-03-2006 at 02:18 PM GMT]
[Edited by eddom on 21-03-2006 at 02:19 PM GMT]
|
|
21-03-2006 at 06:17 AM |
|
|
Goran Level: Moderator
 Registered: 16-05-2002 Posts: 1681
|
Re: Met problem again with API
It is cauing an error because again you didnt create a buffer for GetMac2 big enough to accept the data
GetMac = Space(DataSize)
GetMac = Space(DataSize) <---------------- |
should be
____________________________
If you find the answer helpful, please mark this topic as solved.
|
|
21-03-2006 at 12:50 PM |
|
|
|
|
 |
 |