Solved

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

Posted on 2000-02-27
3
293 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
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 technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

737 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