borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (doubt regarding differences of vb and vb.net)Next Topic (Read and Set Regional Settings) New Topic New Poll Post Reply
AndreaVB Forum : API : Met problem again with API Solved Topic
Poster Message
eddom
Level: Big Cheese

Registered: 14-03-2006
Posts: 24

icon 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
View Profile Send Email to User Show All Posts | Quote Reply
Goran
Level: Moderator

Registered: 16-05-2002
Posts: 1681
icon 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

GetMac2=space(datasize2)


____________________________
If you find the answer helpful, please mark this topic as solved.

21-03-2006 at 12:50 PM
View Profile Send Email to User Show All Posts | Quote Reply
eddom
Level: Big Cheese

Registered: 14-03-2006
Posts: 24
icon Re: Met problem again with API

haha, i didnt see that, sorry. cox use copy and paste

22-03-2006 at 02:33 AM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : API : Met problem again with API Solved Topic
Previous Topic (doubt regarding differences of vb and vb.net)Next Topic (Read and Set Regional Settings) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder