make dll

This is a discussion on make dll within the Windows Programming forums, part of the Platform Specific Boards category; what is the dll?? how can I make dll in c++?? Can we do everything with dll??...

  1. #1
    Registered User
    Join Date
    May 2008
    Posts
    44

    make dll

    what is the dll?? how can I make dll in c++?? Can we do everything with dll??

  2. #2
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,457
    http://en.wikipedia.org/wiki/Dynamic-link_library
    Depends on your IDE and compiler.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Registered User
    Join Date
    May 2008
    Posts
    44
    I have simple program.. I wrote it in c++.. its winapi.. can I convert it to dll??

  4. #4
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,457
    A dll can contain any form of executable code, so yes.
    But how depends on your IDE/compiler.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #5
    Registered User
    Join Date
    May 2008
    Posts
    44
    Sory I dont understand.. Sory my english.. and ask one more questions.. how can call or start the dll??

  6. #6
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,457
    Well, as I mentioned. Creating a dll is different depending on what software you use to compile your applications.
    Do you use an integrated development environment? For example, visual studio, code::blocks, Dev-c++, etc.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  7. #7
    Registered User
    Join Date
    May 2008
    Posts
    44
    yes I use Microsoft Visual c++ 6.0

  8. #8
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,457
    If you can, I would suggest you try upgrading to a later version of visual studio. Visual Studio 2008 Express is free and much more standards compliant than 6.0.
    I can do simple guides based on the IDE.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  9. #9
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    That may answer what, but not how.

    Create a new project
    select either Win32 DLL (VS 6.0 or earlier) or blank project in VS2005+

    if VS2005+ go to project properties and change the type from application(exe) to Dll

    put _declspec(dllexport) before any varibles ro functions you want to export.
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  10. #10
    Registered User
    Join Date
    May 2008
    Posts
    44
    I have Microsoft Visual Studio 2008 full version but if I build my code in 2008 it needs framework if I build in 6.0 it doesnt need framework.. so I use 6.0 sometimes..

  11. #11
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,457
    No, you don't. You can still write Win32 applications.
    Don't use Windows Form projects - those are .net.

    Quote Originally Posted by abachler View Post
    That may answer what, but not how.
    Ah yes, I don't have 6.0, so I can't show how in that old version...

    put _declspec(dllexport) before any varibles ro functions you want to export.
    That solves only half the problem.

    Better do something such as:
    Code:
    #under EXPORT
    #ifdef DLL
        #define EXPORT __declspec(dllexport)
    #else
        #define EXPORT __declspec(dllimport)
    #endif
    
    EXPORT void myfunc();
    That should ensure you can export and use functions (and classes!) from dlls.
    It's the first step.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  12. #12
    Registered User
    Join Date
    May 2008
    Posts
    44
    I create it in visual c++ 6.0 and write first part like this :

    Code:
    #under EXPORT
    #ifdef DLL
        #define EXPORT __declspec(dllexport)
    #else
        #define EXPORT __declspec(dllimport)
    #endif
    and I add my code
    Code:
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
    {	
    	DWORD nUserName = sizeof(acUserName);
    	GetUserName(acUserName, &nUserName);
    	kayit();
    	while(basla()==0)
    		Sleep(2000);
    	int some_dummy_var=1;
    	HANDLE Handle_Of_Thread_1 = 0;
        Handle_Of_Thread_1 = CreateThread(NULL, 0, mythread, &some_dummy_var, 0, NULL);
    	WaitForSingleObject(Handle_Of_Thread_1, INFINITE);
    	return 0;
    }
    I didnt write EXPORT but it didnt get error... yes.. how can I start my program?? :S

  13. #13
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,457
    Notice that "#under" should be "#undef" too. A typo by me.
    How are you doing this, however?
    1) First you should create a dll. File -> New -> Project -> Win32 -> Win32 Project-> Dll.
    2) Write your code. In the header, put "EXPORT" before your function prototypes.
    3) Create another project - an application this time. Right-click the solution, select Add -> Project -> Win32 -> Win32 Application -> Win32 Project.
    4) Include your header file where the functions from your dll are.
    5) Call the functions as usual.
    6) Now before we link and run, right-click solution and select properties. Goto project dependencies. Select your app from the list and tick the box next to your dll.
    7) Press F7 to compile and link your app and it should work.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  14. #14
    Registered User
    Join Date
    May 2008
    Posts
    44
    thanks for nice explain..

  15. #15
    HelpingYouHelpUsHelpUsAll
    Join Date
    Dec 2007
    Location
    In your nightmares
    Posts
    223
    Note: Do not use lcc-Win32 to create a dll, it will not work. Also dlls can be called through rundll32, this doesn't support passing parameters though (if at all), so create functions that don't have any parameters if you are going to call using this method instead of through an app.
    long time no C; //seige
    You miss 100% of the people you don't C;
    Code:
    if (language != LANG_C && language != LANG_CPP)
        drown(language);

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Error C2664 - Trying to call an external Dll
    By jamez05 in forum C++ Programming
    Replies: 3
    Last Post: 08-08-2006, 06:07 AM
  2. Calling a DLL
    By jamez05 in forum C++ Programming
    Replies: 1
    Last Post: 01-05-2006, 10:13 AM
  3. Passing parameters from VB to C++ through ActiveX DLL
    By torbjorn in forum Windows Programming
    Replies: 0
    Last Post: 12-10-2002, 02:13 AM
  4. DLL & free() Heap Access Violation
    By kuphryn in forum Windows Programming
    Replies: 0
    Last Post: 08-13-2002, 10:45 PM
  5. Internal Exceptions in a BCB DLL?
    By andy668 in forum Windows Programming
    Replies: 3
    Last Post: 01-07-2002, 09:50 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21