Does Win32 API use 64 bit length pointers on 64 bit system ?

Diakov Dmytro 1 Reputation point
2020-12-21T12:19:30.23+00:00

Hi!
I have Win32 API (cloud filter api). On Windows 10 x64 it does not work when I create x64 app and pass IntPtr to it's function . (I have access violation memory exception).
But when I build x86 app and use IntPtr with 32 length it works.
So my question is: win32 api is 32 bitness API and can work only with pointers with 32 bits length, is it true ?

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,422 questions
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. David Lowndes 4,711 Reputation points
    2020-12-21T12:22:41.527+00:00

    On 64-bit Windows (with a 64-bit application), pointers are 64-bit.
    You'll have to give some more details about what you're doing. Presumably there's something amiss somewhere.


  2. RLWA32 40,286 Reputation points
    2020-12-21T12:36:30.74+00:00

    Make sure that your managed code is actually running as 64-bit code. An IntPtr is 32-bits in 32-bit code and 64-bits in 64-bit code.

    Check to make sure that you are not building managed code for AnyCpu with prefer 32-bits selected.


  3. RLWA32 40,286 Reputation points
    2020-12-21T13:22:35.213+00:00

    An access violation can result for any number of reasons. Chances are that there is a problem in the code that is exposed when building for x64.


  4. Rita Han - MSFT 2,161 Reputation points
    2020-12-22T05:38:52.813+00:00

    Hello @Diakov Dmytro ,

    CfExecute API works well with 64 bit length pointers on 64 bit system in C++. You can test official sample: CloudMirror and get pointer size using sizeof(). The following snapshot shows an example and its result.

    50256-screenshot-2020-12-22-133436.jpg

    Thank you!


    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.