Search code examples
visual-c++lnk2019

LNK2019 unable to use GetStagedPackageOrigin()


I have been trying to use the GetStagedPackageOrigin() to get the origin of a specific application in my system.

But my program is not compiling because of an unresolved external error.

Error LNK2019 : unresolved external symbol __imp__GetStagedPackageOrigin@8 referenced in function "void __cdecl check(wchar_t const *)" (?check@@YAXPB_W@Z)

Here is my code:

void check(__in PCWSTR fullName)
{ 
    PackageOrigin origin;
    LONG rc = GetStagedPackageOrigin(fullName, &origin);
    if (rc == ERROR_SUCCESS)
    {
        static PCWSTR originstring[] = {L"Unknown",L"Unsigned",L"Inbox",L"Store",L"DeveloperUnsigned",L"DeveloperSigned",L"LineOfBusiness" };
        PCWSTR str = originstring[origin];
        wcout << str << endl;
    }
}

Why does this error keep coming and is there any way to resolve that?


Solution

  • I used dumpbin command in the visual studio command prompt and that function was not being exported from kernel32.dll. The function was not present in the dll in the first place. I think that is why the error occured.