Avatar of Peter Chan
Peter Chan
Flag for Hong Kong asked on

Run .dll file

I've built one .dll file using VS 2008. How to directly run it?
CC#Microsoft Legacy OS

Avatar of undefined
Last Comment
Guy Hengel [angelIII / a3]

8/22/2022 - Mon
Rikin Shah


It is not executable. DLL's cannot be run directly. You need to refer it to other project and use its methods and properties per your needs.

Create any executable (console/windows) project and refer (add it to references) your created DLL to it.

Peter Chan

Many thanks. Can I have the details to show the relevant Form that is from the .dll file, from another console/windows project?

Some more information.
DLL stands for Dynamic Link Library.
That roughly translated is a collection of code that is available to ANY program that understands the interface.  Any application can call a function exposed to run a standard set of code.  The calling app can be coded in a completely different language and has no knowledge of how the task is performed.  Because it is dynamic it means the code is stored in the dll - not in any app you code that uses it.

Think of what it would be like for you to have to write code to display the frame of a form every time you wanted a form ....
Your help has saved me hundreds of hours of internet surfing.
Rikin Shah


I have already included a link http://msdn.microsoft.com/en-us/library/ms235636.aspx. Go throgh these steps.

if the dll is in c or c++ you might think to provide a header file which declares all the exported functions and classes:

// myheader.h
#ifndef MYHEADER_H
#define MYHEADER_H

// put here the include files needed to compile the header
#include <...>

// the following makes your header an import header for other projects
// and an export header for the dll project itself. 
// define MYDLL_EXPORTS in the c++ - precprocessor macros for both debug and release config

#define MYDLL_API __declspec(dllexport)
#define MYDLL_API __declspec(dllimport)

// exported c  functions functions
#ifdef __cplusplus
extern "C"

MYDLL_API void some_exported_function(int, char*);

#ifdef __cplusplus

// exported classes (or structs)

#ifdef __cplusplus

class MYDLL_API SomeExportedClass

// more classes

#endif  //  __cplusplus

#endif // MYHEADER_H

Open in new window

with the above you can access functions and classes from other c/c++ projects if you link against the .lib which is output from your dll project.

Guy Hengel [angelIII / a3]

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Easwaran Paramasivam

DLLs could not be run directly. Instead you can create a Executable application such as console or Windows application and call required the methods of the DLL in the EXE or In the Windows Forms application in each button click call each method separately.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Peter Chan

I want to raise the form, that is inside one compiled .dll file, within the macro of Outlook. How?
Guy Hengel [angelIII / a3]

again, you refer to the class/method of the .dll and run the necessary function. the form as such is not "alone" in that .dll, and if it was somebody else that has developed that .dll, he should have given some instructions on how to "call" that form.

now you refer to a macro in outlook, hence the topics are not correct (C, C# ...)