Solved

Calling proc (no params or ret val) why is call skipped?

Posted on 2000-02-27
3
286 Views
Last Modified: 2010-04-02
I defined a REALLY SIMPLE dll in Delphi 4 which houses 1 function that doesn't take paramters and doesn't return anything.  When I call it from VC++, the loadLibrary call works, and the getProcAddr also works (seems to return a non null value...), but VC++ seems to SKIP MY CALL to the actual dll procedure.  Perhaps I have the syntax of the call wrong?

---------------------- VC++ test code
// testdll1.cpp : Defines the entry point for the application.
//

#include "stdafx.h"

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
       // TODO: Place code here.

    HINSTANCE hDLL;
    FARPROC ProcAdd;

    hDLL = LoadLibrary("a1.dll");
    ProcAdd = GetProcAddress(hDLL,"ANDY0");
    if (ProcAdd == NULL) return 0;

    ProcAdd;    // THIS IS SKIPPED????

    return 0;
}
------------------------
0
Comment
Question by:abulka
  • 2
3 Comments
 
LVL 32

Accepted Solution

by:
jhance earned 50 total points
ID: 2563293
Try it like this instead:

typedef void (WINAPI * PFANDYO)(void);

{
  PFANDYO pfANDYO;
  HINSTANCE hDLL;

  hDLL = LoadLibrary("a1.dll");

  pfANDYO = (PFANDYO)GetProcAddress(hDLL, "ANDYO");

  pfANDYO();

  return 0;
}
0
 
LVL 22

Expert Comment

by:nietod
ID: 2563500
The key difference there is the "()" after the function pointer.  That is the "fucntion call operator", telling the compiler to call the function.
0
 
LVL 32

Expert Comment

by:jhance
ID: 2564199
>The key difference there is the "()"
>after the function pointer.  

Yes, I mean to to say that...

I also find it's helpful to declare the call properly.  This is especially useful when calling DLL functions with arguments.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SendMessage fails while PostMessage works 2 122
Find Visual Studio Tools 2 111
Dynamically allocate memory 9 62
White board coding practice 3 90
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question