Jump to content


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.
Photo

Coding a Standard DLL


4 replies to this topic

Neo

Neo
  • Members
  • 48 posts

Posted 31 July 2003 - 08:01

Hi

I am pretty new to DLL Programming. Out of sheer curiousity i wanted to use my own Standard DLL as a custom action. I do not have VC++ with me so I am using BloodShed Dev-Cpp 5. I have a simple MyFunction which displays a messagebox and returns a string. The function definition is something like this.

CODE

__declspec(dllexport) char* MyFunction();


I'm sure that it works coz i have a simple console application which uses this dll. It goes something like this

CODE

....
__declspec(dllimport) char* MyFunction();
....
//in the main function
cout<<MyFunction()<<endl;
...


This works absolutely fine. But when i call it in the installer it says that the function is not exported.
Please Help.

Thanks in advance.

Regards

Neo.



Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 31 July 2003 - 08:26

The DLL name may be mangled. You can check this by opeing your DLL in Dependency Walker.
You may need to use a .def file to avoid this.

Neo

Neo
  • Members
  • 48 posts

Posted 31 July 2003 - 09:29

Hi Stefan

Thanks for your quick response. I did read about the def file and created one like this.

CODE

LIBRARY DLLProject

FUNCTIONS
MyFunction


But I dont know how to use it. unsure.gif The manual asks me to use a --def filename.def option with the compilier but it does not work. Please help.

Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 31 July 2003 - 09:38

Well, you would have to find this information in the documentation for your compiler.

Neo

Neo
  • Members
  • 48 posts

Posted 31 July 2003 - 12:46

Hi Stefan

It finally worked. I used the extern "C" keyword before __declspec to instruct the compiler to avoid name mangling. Thanks for your support.

Regards

Neo