How to use VirtualAlloc2 memory api

Akali 21 Reputation points
2020-10-17T06:33:49.107+00:00

Encountered a problem while compiling, error LNK2019: unable to resolve external symbols __imp_VirtualAlloc2.
But VirtualAlloc is fine.

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,432 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,548 questions
0 comments No comments
{count} votes

Accepted answer
  1. Viorel 112.8K Reputation points
    2020-10-17T08:14:22.2+00:00

    Try adding this line to any source file:

    #pragma comment(lib, "mincore")

    (Or add mincore.lib to linker options).

    And check that the function works.

    3 people found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Rita Han - MSFT 2,161 Reputation points
    2020-10-19T03:15:58.937+00:00

    Hello @04419928,

    Thanks for binging this to our attention.

    I can reproduce this issue. I've reported it internally and will update here if there is any progress.

    Use mincore.lib instead as @Viorel pointed out.

    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.

    1 person found this answer helpful.
    0 comments No comments