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. Calling an function in a DLL

Calling an function in a DLL

Scheduled Pinned Locked Moved C / C++ / MFC
data-structureshelpquestion
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.
  • J Offline
    J Offline
    JJeffrey
    wrote on last edited by
    #1

    I'm sorry to disturb all of you, I feel like I'm missing something here. I'm trying to use call a function in a DLL I have written and have so far done this: DLL Side int __stdcall Topo(LPSTR Param) { `}` Calling Function side `typedef int (__stdcall * FuncPtr)(LPTSTR); int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { HMODULE TopoPtr; FuncPtr TopoFunc; CHAR Output[50]={0}; if (TopoPtr = (HMODULE) LoadLibrary ("") ) { TopoFunc = (FuncPtr)GetProcAddress(TopoPtr, "Topo"); if ( TopoFunc && TopoPtr ) { TopoFunc(); } FreeLibrary ( TopoPtr ); } return 0; }` Export.def `LIBRARY CheckTopo EXPORTS Topo @1` The error is this: When I call TopoFunc, I get a stack overflow. Tracing it by stepping through, I find that the stack overflow occurs BEFORE I enter the code in the DLL Side. Is there something wrong with my calling of the function? Or is it nothing to do with that and that I should be looking at something else?

    P S 2 Replies Last reply
    0
    • J JJeffrey

      I'm sorry to disturb all of you, I feel like I'm missing something here. I'm trying to use call a function in a DLL I have written and have so far done this: DLL Side int __stdcall Topo(LPSTR Param) { `}` Calling Function side `typedef int (__stdcall * FuncPtr)(LPTSTR); int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { HMODULE TopoPtr; FuncPtr TopoFunc; CHAR Output[50]={0}; if (TopoPtr = (HMODULE) LoadLibrary ("") ) { TopoFunc = (FuncPtr)GetProcAddress(TopoPtr, "Topo"); if ( TopoFunc && TopoPtr ) { TopoFunc(); } FreeLibrary ( TopoPtr ); } return 0; }` Export.def `LIBRARY CheckTopo EXPORTS Topo @1` The error is this: When I call TopoFunc, I get a stack overflow. Tracing it by stepping through, I find that the stack overflow occurs BEFORE I enter the code in the DLL Side. Is there something wrong with my calling of the function? Or is it nothing to do with that and that I should be looking at something else?

      P Offline
      P Offline
      prasad_som
      wrote on last edited by
      #2

      JJeffrey wrote:

      TopoFunc();

      Did you miss to pass string here ?

      Prasad Notifier using ATL | Operator new[],delete[][^]

      J 1 Reply Last reply
      0
      • J JJeffrey

        I'm sorry to disturb all of you, I feel like I'm missing something here. I'm trying to use call a function in a DLL I have written and have so far done this: DLL Side int __stdcall Topo(LPSTR Param) { `}` Calling Function side `typedef int (__stdcall * FuncPtr)(LPTSTR); int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { HMODULE TopoPtr; FuncPtr TopoFunc; CHAR Output[50]={0}; if (TopoPtr = (HMODULE) LoadLibrary ("") ) { TopoFunc = (FuncPtr)GetProcAddress(TopoPtr, "Topo"); if ( TopoFunc && TopoPtr ) { TopoFunc(); } FreeLibrary ( TopoPtr ); } return 0; }` Export.def `LIBRARY CheckTopo EXPORTS Topo @1` The error is this: When I call TopoFunc, I get a stack overflow. Tracing it by stepping through, I find that the stack overflow occurs BEFORE I enter the code in the DLL Side. Is there something wrong with my calling of the function? Or is it nothing to do with that and that I should be looking at something else?

        S Offline
        S Offline
        ShilpiP
        wrote on last edited by
        #3

        in loadlibrary first u enter the dll name. and to debug dll ,open workspace of dll and open Projects->setting->Debug and in executable for debug section ,give path name of client exe and then debug it

        Yes U Can ...If U Can ,Dream it , U can do it ...ICAN

        1 Reply Last reply
        0
        • P prasad_som

          JJeffrey wrote:

          TopoFunc();

          Did you miss to pass string here ?

          Prasad Notifier using ATL | Operator new[],delete[][^]

          J Offline
          J Offline
          JJeffrey
          wrote on last edited by
          #4

          No, I just removed all the irrelevant code. I did remember to pass the string. It is a LPTSTR. And as to the other poster's statement, been there, done that. It is calling into the debug dll correctly, but the stack overflows when the program steps through from the calling EXE to the debug DLL in VC++

          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