Solved

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

Posted on 2000-02-27
3
298 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
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.

691 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