I have a Type 1 CA which is implemented in c++.
C++ Code
--------------------------------------
#pragma comment(lib, "msi.lib")
#include "stdafx.h"
#include <msi.h>
#include <msiquery.h>
#include <windows.h>
#using <system.dll>
#using <mscorlib.dll>
#include <tchar.h>
using namespace System;
using namespace System::Reflection;
using namespace System::Windows::Forms;
extern "C" UINT __stdcall Test(MSIHANDLE hMSI)
{
int _hMSI = hMSI;
array< int ^>^ args = { _hMSI };
TCHAR szSupportDir[1024];
DWORD dwBuff = sizeof(szSupportDir);
MsiGetProperty(hMSI,L"SUPPORTDIR",szSupportDir,&dwBuff);
MessageBox::Show(Convert::ToString(szSupportDir));
return ERROR_SUCCESS;
}
When I compiled, there were some error thrown.
Errors:
error LNK2028: unresolved token (0A000014) "extern "C" unsigned int __stdcall MsiGetPropertyW(unsigned long,wchar_t const *,wchar_t *,unsigned long *)" (?MsiGetPropertyW@@$$J216YGIKPB_WPA_WPAK@Z) referenced in function "extern "C" unsigned int __stdcall Test(unsigned long)" (?Test@@$$J14YGIK@Z)
error LNK2019: unresolved external symbol "extern "C" unsigned int __stdcall MsiGetPropertyW(unsigned long,wchar_t const *,wchar_t *,unsigned long *)" (?MsiGetPropertyW@@$$J216YGIKPB_WPA_WPAK@Z) referenced in function "extern "C" unsigned int __stdcall Test(unsigned long)" (?Test@@$$J14YGIK@Z)
fatal error LNK1120: 2 unresolved externals
Any help to solve this problem!!!
This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
C++ Compilation error
Started by
BCL
, Jul 23 2007 19:05
4 replies to this topic
Posted 24 July 2007 - 01:51
Sorry I am new to VC++. How do I link the msi.lib to the project. Thanks for the help.
Posted 24 July 2007 - 05:30
You're welcome.
Assuming you're using VC 2005, go to the Project -> Properties off the menubar.
Then select Configuration Properties -> Linker -> Input.
For the Additional Properties value add msi.lib. Separate it with a semi-colon if there's already a value there. Also remember to add it for each configuration - usually Debug and Release.
Assuming you're using VC 2005, go to the Project -> Properties off the menubar.
Then select Configuration Properties -> Linker -> Input.
For the Additional Properties value add msi.lib. Separate it with a semi-colon if there's already a value there. Also remember to add it for each configuration - usually Debug and Release.
Posted 24 July 2007 - 20:25
Thank you guys for ypur help. I was using VS.Net 2005 Professional edition.
I found that the MSI.lib is not linked to the VC++ project in VS.Net 2005. After configuring the VS.Net options to link the file "msi.lib" to my project ,the problem got solved.
I found that the MSI.lib is not linked to the VC++ project in VS.Net 2005. After configuring the VS.Net options to link the file "msi.lib" to my project ,the problem got solved.