I know that simply posting code and asking for a solution isn't a good idea, but I have no idea what's causing this.
I'm trying to find the installation path of PowerPoint based on this code, however, the compiler gives this error:
error LNK2019: unresolved external symbol _MsiLocateComponentW@12 referenced in function _WinMain@16
I'm using Visual Studio 2019 and IntelliSense doesn't notice the error, only the compiler. Here's the code:
#include <Windows.h>
#include <msi.h>
int APIENTRY WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int nShowCmd) {
LPCWSTR PowerPoint = L"{CC29E94B-7BC2-11D1-A921-00A0C91E2AA2}";
DWORD size = 300;
INSTALLSTATE installstate;
LPWSTR sPath;
sPath = new wchar_t[size];
installstate = MsiLocateComponent(PowerPoint, sPath, &size);
if (installstate == INSTALLSTATE_LOCAL || installstate == INSTALLSTATE_SOURCE)
MessageBox(NULL, sPath, L"PowerPoint path", MB_OK | MB_ICONASTERISK );
delete[] sPath;
return 0;
}
As you can see, I included the msi.h
header. What's wrong with my code?