Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Conversion of VC++ char array from client side to Delphi String at Server Side

Conversion of VC++ char array from client side to Delphi String at Server Side

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++delphicomsysadmin
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    CraZyToLearn
    wrote on last edited by
    #1

    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

    C M 2 Replies Last reply
    0
    • C 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

      C Offline
      C Offline
      CraZyToLearn
      wrote on last edited by
      #2

      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 :)

      1 Reply Last reply
      0
      • C 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

        M Offline
        M Offline
        Matthew Faithfull
        wrote on last edited by
        #3

        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.

        C 1 Reply Last reply
        0
        • M Matthew Faithfull

          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.

          C Offline
          C Offline
          CraZyToLearn
          wrote on last edited by
          #4

          Thanks Matthew, Still I am trying.

          :) CraZyToLearn :)

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups