Conversion of VC++ char array from client side to Delphi String at Server Side
-
I am sending login credentials through ActiveX Control developed in VC++ 6.0 to Server side which is developed in Delphi //Client side struct in VC++ 6.0 typedef struct { char User[41]; char Password[41]; char ClientVersion[41]; char EndCode[2]; }TNetConnectCheck; //Server side struct in Delphi6 TNetConnectCheck = record UserName : string[40]; Password : string[40]; ClientVersion : String[40]; // Added by Ravi on : 03/08/2006 EndCode : array[0..1] of Char; end; but, I am getting some junk characters in the strings at serverside eg. User name like 'CrazyToLearn#0...#0' I want to send the packet which is having the length 125 to server with exact 'CrazyToLearn' not with any padding 0 or junk characters. I tried all the trims dynamic char array but cant solve the problem, Please instant help will be really appriciated... THANX CraZyToLearn
-
I am sending login credentials through ActiveX Control developed in VC++ 6.0 to Server side which is developed in Delphi //Client side struct in VC++ 6.0 typedef struct { char User[41]; char Password[41]; char ClientVersion[41]; char EndCode[2]; }TNetConnectCheck; //Server side struct in Delphi6 TNetConnectCheck = record UserName : string[40]; Password : string[40]; ClientVersion : String[40]; // Added by Ravi on : 03/08/2006 EndCode : array[0..1] of Char; end; but, I am getting some junk characters in the strings at serverside eg. User name like 'CrazyToLearn#0...#0' I want to send the packet which is having the length 125 to server with exact 'CrazyToLearn' not with any padding 0 or junk characters. I tried all the trims dynamic char array but cant solve the problem, Please instant help will be really appriciated... THANX CraZyToLearn
Please consider the statement I forgot to mention in the post is : "I dont have to change code at server side,whatever we want to modify , its only at client side"
:) CraZyToLearn :)
-
I am sending login credentials through ActiveX Control developed in VC++ 6.0 to Server side which is developed in Delphi //Client side struct in VC++ 6.0 typedef struct { char User[41]; char Password[41]; char ClientVersion[41]; char EndCode[2]; }TNetConnectCheck; //Server side struct in Delphi6 TNetConnectCheck = record UserName : string[40]; Password : string[40]; ClientVersion : String[40]; // Added by Ravi on : 03/08/2006 EndCode : array[0..1] of Char; end; but, I am getting some junk characters in the strings at serverside eg. User name like 'CrazyToLearn#0...#0' I want to send the packet which is having the length 125 to server with exact 'CrazyToLearn' not with any padding 0 or junk characters. I tried all the trims dynamic char array but cant solve the problem, Please instant help will be really appriciated... THANX CraZyToLearn
I'm no Delphinium but as a general approach you need to determine the byte count sizes of the types involved e.g. sizeof(TNetConnectCheck) and make sure they match up. You might also want to control the data type alignment on the client side, see #pragma push pack : 1 (That syntax is wrong so you'll need to search ) or __align your client side data type. You also need to check whether the string types on the Delphi side are NULL terminated or not and setup the client side data appropriately. Finally you need to check the calling convention, e.g. __cdecl, __stdcall or Delphi equivalents of the actual call between the two modules and make sure both sides are expecting the same behaviour in terms of stack cleanup. I suspect this last part is already OK or you would not be getting as close as you are but it does no harm to check and be sure you understand what's happening under the hood. :)
Nothing is exactly what it seems but everything with seems can be unpicked.
-
I'm no Delphinium but as a general approach you need to determine the byte count sizes of the types involved e.g. sizeof(TNetConnectCheck) and make sure they match up. You might also want to control the data type alignment on the client side, see #pragma push pack : 1 (That syntax is wrong so you'll need to search ) or __align your client side data type. You also need to check whether the string types on the Delphi side are NULL terminated or not and setup the client side data appropriately. Finally you need to check the calling convention, e.g. __cdecl, __stdcall or Delphi equivalents of the actual call between the two modules and make sure both sides are expecting the same behaviour in terms of stack cleanup. I suspect this last part is already OK or you would not be getting as close as you are but it does no harm to check and be sure you understand what's happening under the hood. :)
Nothing is exactly what it seems but everything with seems can be unpicked.
Thanks Matthew, Still I am trying.
:) CraZyToLearn :)