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. function from dll

function from dll

Scheduled Pinned Locked Moved C / C++ / MFC
help
4 Posts 3 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.
  • _ Offline
    _ Offline
    _crs_
    wrote on last edited by
    #1

    Hi, My problem : I want to call a function from a DLL and isn't working the function is : // this code is from dll ...... DWORD test(DWORD x) { if (x==1) MessageBox(NULL, "work DLL", "working", MB_OK); return 0; } // ............ in my program I wrote : typedef DWORD (*LPtest)(DWORD); LPtest test = NULL; hDll = LoadLibrary("test.dll"); test = (LPtest)GetProcAddress(hDll,"test"); DWORD a = GetLastError(); hDll is not NULL .... and .... a is 127 ... "The specified procedure could not be found." and if I try something like test(1); the program gets an ACCESS VIOLATION ! please help !!!

    V C 2 Replies Last reply
    0
    • _ _crs_

      Hi, My problem : I want to call a function from a DLL and isn't working the function is : // this code is from dll ...... DWORD test(DWORD x) { if (x==1) MessageBox(NULL, "work DLL", "working", MB_OK); return 0; } // ............ in my program I wrote : typedef DWORD (*LPtest)(DWORD); LPtest test = NULL; hDll = LoadLibrary("test.dll"); test = (LPtest)GetProcAddress(hDll,"test"); DWORD a = GetLastError(); hDll is not NULL .... and .... a is 127 ... "The specified procedure could not be found." and if I try something like test(1); the program gets an ACCESS VIOLATION ! please help !!!

      V Offline
      V Offline
      valikac
      wrote on last edited by
      #2

      Does your DLL compile correctly? There is no export code. extern "C" __declspec(dllexport) DWORD Test(DWORD) Kuphryn

      1 Reply Last reply
      0
      • _ _crs_

        Hi, My problem : I want to call a function from a DLL and isn't working the function is : // this code is from dll ...... DWORD test(DWORD x) { if (x==1) MessageBox(NULL, "work DLL", "working", MB_OK); return 0; } // ............ in my program I wrote : typedef DWORD (*LPtest)(DWORD); LPtest test = NULL; hDll = LoadLibrary("test.dll"); test = (LPtest)GetProcAddress(hDll,"test"); DWORD a = GetLastError(); hDll is not NULL .... and .... a is 127 ... "The specified procedure could not be found." and if I try something like test(1); the program gets an ACCESS VIOLATION ! please help !!!

        C Offline
        C Offline
        codeant
        wrote on last edited by
        #3

        It sound likes that you does not export the function "DWORD test(DWORD x)", you can get your current exports table via typing "dumpbin /exports test.dll" in console. In normally, VC6 exports your test function in this form: _test@2 For telling the compiler we need to export this function in standard mode, save follow lines in notepad in a .def file and then add it to your dll project: EXPORTS test At the end, change declares line "DWORD test(DWORD x)" to "__declspec(dllexport) DWORD test(DWORD x)" for avoid the warning(dllexport assumed). Good Luck.

        _ 1 Reply Last reply
        0
        • C codeant

          It sound likes that you does not export the function "DWORD test(DWORD x)", you can get your current exports table via typing "dumpbin /exports test.dll" in console. In normally, VC6 exports your test function in this form: _test@2 For telling the compiler we need to export this function in standard mode, save follow lines in notepad in a .def file and then add it to your dll project: EXPORTS test At the end, change declares line "DWORD test(DWORD x)" to "__declspec(dllexport) DWORD test(DWORD x)" for avoid the warning(dllexport assumed). Good Luck.

          _ Offline
          _ Offline
          _crs_
          wrote on last edited by
          #4

          thank you very much ! I wrote a .def file, linked and it worked !!!! thank you !

          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