小弟急求DLL源代码,(能实现任意一个小功能就行,不用太大),希望大哥们能附上简单的说明,万分感激啊

解决方案 »

  1.   

    DLL源代码?MSDN及Platform SDK的示例你看过没有?
      

  2.   

    /* 文件名:lib.h */#ifndef LIB_H#define LIB_Hextern "C" int __declspec(dllexport)add(int x, int y);#endif
    /* 文件名:lib.cpp */#include "lib.h"int add(int x, int y){return x + y;}
      

  3.   

    //entry.cpp#define WIN32_LEAN_AND_MEAN
    #include <stdio.h>
    #include <stdlib.h>
    #include <windows.h>
    #include "entry.h"BOOL WINAPI DllMain( HINSTANCE hinstDll,
    DWORD fdwReason,
    LPVOID lpReserved )
    {
    DWORD tid = GetCurrentThreadId(); switch( fdwReason )
    {
    case DLL_PROCESS_ATTACH:
    printf("DLL:\tProcess attach ( tid = %d )\n",tid);
    break;
    case DLL_THREAD_ATTACH:
    printf("DLL:\tThread attach ( tid = %d )\n",tid);
    break;
    case DLL_THREAD_DETACH:
    printf("DLL:\tThread detach ( tid = %d )\n",tid);
    break;
    case DLL_PROCESS_DETACH:
    printf("DLL:\tProcess detach ( tid = %d )\n",tid);
    break;
    }
    return TRUE;
    }_declspec ( dllexport ) BOOL TheFunction()
    {
    printf("DLL:\tThrFunction() called\n");
    return TRUE;
    }//entry.h
    #ifndef ENTRY_H
    #define ENTRY_H
    _declspec ( dllimport ) BOOL TheFunction();
    #endif以前自己的练习,高手默笑哈
      

  4.   

    #define WIN32_LEAN_AND_MEAN
    #include <stdio.h>
    #include <stdlib.h>
    #include <windows.h>
    #include "entry.cpp"_declspec(dllimport) BOOL TheFunction();DWORD WINAPI ThreadFunc ( LPVOID );VOID main(VOID)
    {
    HANDLE hThrd;
    DWORD dwThreadId; hThrd = CreateThread ( NULL,
    0,
    ThreadFunc,
    NULL,
    0,
    &dwThreadId );
    if (hThrd)
    printf("\tThread launched\n");
    WaitForSingleObject(hThrd,INFINITE);
    CloseHandle(hThrd);
    }DWORD WINAPI ThreadFunc(LPVOID n)
    {
    printf("\tThread running \n");
    TheFunction();
    return 0;
    }
    顺便带上驱动
      

  5.   

    www.cppblog.com/wlwlxj里面有一个mfc dll实战你看看
      

  6.   

    http://www.vckbase.com/code/listcode.asp?mclsid=13&sclsid=1303