Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. a problem about dll

a problem about dll

Scheduled Pinned Locked Moved C / C++ / MFC
help
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    yingkou
    wrote on last edited by
    #1

    I have written a dll,codes as below: void __declspec(dllexport) __stdcall TestDialog(HWND hWnd) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); AfxSetResourceHandle(theApp.m_hInstance); AfxEnableControlContainer(); CTestDlg dlg; dlg.DoModal(); AfxSetResourceHandle(AfxGetInstanceHandle()); } void TestHello(HWND hWnd) { hMainDlg=hWnd; MessageBox(hMainDlg,"Hello","Test",MB_OK); } µ÷Ó㺠typedef void (*TestHello)(HWND); TestHello t=NULL; HINSTANCE hin=LoadLibrary("Test.dll"); if(NULL == hin) return ; t=(TestHello)GetProcAddress(hin,"TestHello"); if(NULL == t) return; t(m_hWnd); FreeLibrary(hin); typedef void (__stdcall *TestDlg)(HWND); hin=LoadLibrary("TestHello.dll"); if(NULL == hin) return ; TestDlg t1=(TestDlg)GetProcAddress(hin,"TestDialog"); if(NULL == t1) return; t1(m_hWnd); FreeLibrary(hin); both the dll and exe are ok,but if I change typedef void (*TestHello)(HWND); into typedef void (__stdcall*TestHello)(HWND); Error happens in EXE,correspondingly. typedef void (__stdcall *TestDlg)(HWND); into typedef void (*TestDlg)(HWND); EXE also has a error

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups