Deepti Jain
Deepti Jain

Reputation: 1921

msi.h gives compilation error in dll

I am new to working with DLLs. Though I have done some serious C++ programming on Linux and know what DLLs are. I need to code a windows installer using custom actions. For this I create a new DLL project in Visual studio 2010. When I try to include msi.h in the StdAfx.h file I get the folowing error:

1>------ Build started: Project: CustomAction, Configuration: Debug Win32 ------
1>  DllEntry.cpp
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\msi.h(86): error C2146: syntax error : missing ';' before identifier 'WINAPI'
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\msi.h(86): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\msi.h(86): error C2146: syntax error : missing ';' before identifier 'MsiCloseHandle'
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\msi.h(86): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
......................

The project has nothing apart from StdAfx.cpp which Includes the StdAfx Header and the StdAfx.h file which is this:

#include   <msi.h>
#include   <msiquery.h>
#include   <stdio.h>

I tried adding path to the msi.lib in the linker input properties of the project. It didn't work. I also tried adding path to the lib folder, include folder and bin folder of the windows sdk directory, that also didn't work. What is the cause for this and also if anyone can give me pointers to any tutorial to using custom actions with windows installers as I am a newbie in this area.

Upvotes: 2

Views: 1311

Answers (1)

Greg Hewgill
Greg Hewgill

Reputation: 993881

It looks like <msi.h> depends on the WINAPI macro. Therefore, you may need to include <windows.h> first:

#include <windows.h>
#include <msi.h>

There is nothing special about header files when working with DLLs. Header files work the same way you are already accustomed to.

Upvotes: 5

Related Questions