?
Solved

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

Posted on 2000-02-27
3
Medium Priority
?
303 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 150 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
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.

770 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