Results 1 to 4 of 4

Thread: While changing external function from ANSI to Wide, what to pass as size?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2017
    Location
    Belgium
    Posts
    213

    Default While changing external function from ANSI to Wide, what to pass as size?

    So we are in the process of converting our 19.1 application to 23.0 and I've hit a problem while converting a call to CryptStringToBinaryA.

    It's clear to use WStrings etc but CryptStringToBinaryW expects a pointer to the data AND the size of the data. In the ANSI version it was just the Length() but what to pass for the wide version?
    We have SizeOfString() that returns the amount of UTF8 bytes but is there such a thing for WString?

    Code:
    External_Function CryptStringToBinary "CryptStringToBinaryW" Crypt32.dll Pointer pszString DWord cchString ;
            DWord dwFlags Pointer pbBinary Pointer pcbBinary Pointer pdwSkip Pointer pdwFlags Returns Boolean
    This is what I have currently but have not tested it as I doubt SizeOfString() is correct
    Code:
    Move (CryptStringToBinary(AddressOf(wsBase64),SizeOfString(wsBase64),dwFlags,AddressOf(wsData),AddressOf(dwSize),AddressOf(dwSkip),AddressOf(dwFlags))) to bResult

  2. #2
    Join Date
    Oct 2017
    Location
    Belgium
    Posts
    213

    Default Re: While changing external function from ANSI to Wide, what to pass as size?

    Nevermind stupid me, didn't see there was a SizeOfWString function... d'oh.

  3. #3
    Join Date
    Feb 2009
    Location
    The Netherlands
    Posts
    4,544

    Default Re: While changing external function from ANSI to Wide, what to pass as size?

    Did you see SizeOfWString? This gives the number of code units and it is what API's expecting a wide string usually want.

  4. #4
    Join Date
    Feb 2009
    Location
    The Netherlands
    Posts
    4,544

    Default Re: While changing external function from ANSI to Wide, what to pass as size?

    No worries, glad you found it.. BTW, I moved this thread to the Unicode and 64-bit forum..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •