473,387 Members | 1,304 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Re-exporting functions from dynamically linked DLL

Hi,

I have the following situation:

I have a 3rd party DLL which does not include a LIB file, just a header file
with typedef declarations for exported functions (It is intended for dynamic
linking)

I need to wrap the DLL to allow for callbacks to my own code (in Lisp), and
to do this I need to load the DLL using LoadLibrary and access each function
that I need using GetProcAddress.
So for example:

The third party header will say:
typedef INT (WINAPI * lp_function)();

Then in my c wrapper file:
#include "3rdparty.h"

#ifdef _WIN32
#define DllExport __declspec(dllexport)
#else
#define DllExport
#endif

HINSTANCE hInstance;
lp_function f1;

DllExport int initialiseAPI()
{
if(NULL==(hInstance=LoadLibrary("demoapi.dll")))
{
return 1;
}

if(NULL==(f1=(lp_function)GetProcAddress(hInstance ,"function")))
{
return 1;
}

}

etc.

The I implement the callback code which in turn calls code on my Lisp side.

So my question is:
I want to re-export these dynamically linked functions. I could easily
wrap them:

DllExport void wrappedf1 (int arg)
{
f1(arg);
}

but I would prefer to just declare it as exported somehow. If I try
something like changing their header file to say:
typedef DllExport INT (WINAPI * lp_function)();

and my code to declare:
DllExport lp_function f1;

I get a Segmentation Violation.

Anyone have any ideas?


Jul 23 '05 #1
2 1769
Kevin Crosbie wrote:
I have a 3rd party DLL which does not include a LIB file, just a header file
with typedef declarations for exported functions (It is intended for dynamic
linking)

I need to wrap the DLL to allow for callbacks to my own code (in Lisp), and
to do this I need to load the DLL using LoadLibrary and access each function
that I need using GetProcAddress.

[...]
Anyone have any ideas?


Wrong newsgroup. DLLs are not part of C++ language, they are quite
platform-specific. Post to comp.os.ms-windows.programmer.win32 or to
a newsgroup for your C++ compiler.

V
Jul 23 '05 #2

"Victor Bazarov" <v.********@comAcast.net> wrote in message
news:Pb******************@newsread1.mlpsca01.us.to .verio.net...
Wrong newsgroup. DLLs are not part of C++ language, they are quite
platform-specific. Post to comp.os.ms-windows.programmer.win32 or to
a newsgroup for your C++ compiler.

V


Will do. Thanks Victor.
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Nel | last post by:
I have a question related to the "security" issues posed by Globals ON. It is good programming technique IMO to initialise variables, even if it's just $foo = 0; $bar = ""; Surely it would...
4
by: Craig Bailey | last post by:
Anyone recommend a good script editor for Mac OS X? Just finished a 4-day PHP class in front of a Windows machine, and liked the editor we used. Don't recall the name, but it gave line numbers as...
1
by: Chris | last post by:
Sorry to post so much code all at once but I'm banging my head against the wall trying to get this to work! Does anyone have any idea where I'm going wrong? Thanks in advance and sorry again...
11
by: James | last post by:
My form and results are on one page. If I use : if ($Company) { $query = "Select Company, Contact From tblworking Where ID = $Company Order By Company ASC"; }
4
by: Alan Walkington | last post by:
Folks: How can I get an /exec'ed/ process to run in the background on an XP box? I have a monitor-like process which I am starting as 'exec("something.exe");' and, of course the exec function...
1
by: John Ryan | last post by:
What PHP code would I use to check if submitted sites to my directory actually exist?? I want to use something that can return the server code to me, ie HTTP 300 OK, or whatever. Can I do this with...
10
by: James | last post by:
What is the best method for creating a Web Page that uses both PHP and HTML ? <HTML> BLA BLA BLA BLA BLA
8
by: Beowulf | last post by:
Hi Guru's, I have a query regarding using PHP to maintain a user profiles list. I want to be able to have a form where users can fill in their profile info (Name, hobbies etc) and attach an...
1
by: joost | last post by:
Hello, I'm kind of new to mySQL but more used to Sybase/PHP What is illegal about this query or can i not use combined query's in mySQL? DELETE FROM manufacturers WHERE manufacturers_id ...
3
by: presspley | last post by:
I have bought the book on advanced dreamweaver and PHP recently. I have installed MySQL and PHP server but am getting an error on the $GET statement show below. It says there is a problem with...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.