Jump to content

really weird problem


tamir
 Share

Recommended Posts

i have a simple function to create TCP connection:

Func TCPConnect()
    DLLCall("au3xtra.dll","int","TCPStartUp")
    $MainSocket = DllCall("au3xtra.dll", "int", "TCPListen", "str", "127.0.0.1", "int", 9342, "int", 100)
    If @error Or $MainSocket[0] < 0 Then
        MsgBox(0, "", "An error occured")
    Else
                               ... (some other code, nvm)
                EndIf
EndFunc

and another function that opens a "file open dialog":

Func BrowseFilePath($var)
    $select = FileOpenDialog("Browse", @ScriptDir, "(*.exe)", 1+2)
    If Not (@error = 1) Then
        GUICtrlSetData(Eval($var), $select)
    EndIf
EndFunc

when i call the TCPConnect() function it is creating TCP connection and everything working fine.

but if i use the BrowseFilePath() function before then when i try to use TCPConnect() it gives me the error message and $MainSocket somehow equals to 0.

how come that the browse function cause error to the tcp connection?

Link to comment
Share on other sites

As a matter of fact, I think I do. FileOpenDialog() changes the working directory for the script, so when it tries to find the Dll, it sets @error. You have two solutions. Specify the full path to the Dll in the DllCall() line or (I'm assuming the DLL is in @ScriptDir), then change the working directory back with FileChangeDir().

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...