Alright Im new and this is my first post ive always read CodeGuru but just now got stuck with an issue that pretty much conserns me so i found myself here and Im glad to join.
Ill try to make that as strate forward as possable
I got a DLL I made VIA STDCall a Function call Test it takes 3 Params (INT, Char*, Long)
The first is a Port Number, the 2nd is a String that will hold "127.0.0.1", and the Length of the string passed of "127.0.0.1" which will change Via Application passing the Args
Now im calling this function from VB6 using FromUnicode option to format "127.0.0.1" then formatting it further once it Hits the C++ Dll Function Thats fine...
Now it takes that String and put it into a Structure that looks like this
I then useCode:typedef struct { unsigned int Port; char * IP; } ConnectionInformation;
now another function resides in the same dll that CreateThread calls.. now the issue is that right when the function is called I use thisCode:char IPModded[16]; //Max Len of Ip is 15 + Null strcpy(IPModded, ParamIP); IPModded[ParamLenOfIP] = '\0'; // Cut Of Crap from End Of String ConnectionInformation MyStruct; MyStruct.IP = IPModded; MyStruct.Port = ParamPort; MessageBox(0,LPCSTR(MyStruct.IP),LPCSTR("before it goes through"),0); CreateThread(NULL, 0, InitSocketTest, reinterpret_cast<LPVOID>(&MyStruct), 0, 0);
and somewhere in between The CreateThread and Messagebox it Messes up beucase about 10% of the time it shows 127.0.0.1 in the messagebox and the other it Crashes or displays Junk evenly... Any Ideas im sure its something reall simple that I dont see,Code:DWORD WINAPI InitSocketTest(LPVOID lp) { //ConnectionInformation * MyInformation = (ConnectionInformation *)lp; ConnectionInformation * MyInformation = reinterpret_cast<ConnectionInformation *>(lp); unsigned int nPort=MyInformation->Port; //65535 MessageBox(0,LPCSTR(MyInformation->IP),LPCSTR("Information"),0); }
Now once I get the Char Pointer issue handled I am just passing it like this to a Socket Stucture
Is this the correct way to use it?
Thankyou!Code:if ((RemoteSin.sin_addr.S_un.S_addr = inet_addr(MyInformation->IP)) == INADDR_NONE)




Reply With Quote
