Link to home
Start Free TrialLog in
Avatar of Peter Chan
Peter ChanFlag for Hong Kong

asked on

Run .dll file

Hi,
I've built one .dll file using VS 2008. How to directly run it?
Avatar of Rikin Shah
Rikin Shah
Flag of India image

Hi,

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.

http://msdn.microsoft.com/en-us/library/ms235636.aspx
Avatar of Peter Chan

ASKER

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 ....
Hi,

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

#ifdef MYDLL_EXPORTS
#define MYDLL_API __declspec(dllexport)
#else
#define MYDLL_API __declspec(dllimport)
#endif


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

MYDLL_API void some_exported_function(int, char*);

#ifdef __cplusplus
}
#endif

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

Sara
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
Hi,
I want to raise the form, that is inside one compiled .dll file, within the macro of Outlook. How?
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# ...)