🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #1756

CALLBACK Hell

#1756
From: Mike Collins
Date: Thu, 14 Jun 2007 17:35
52 lines
2687 bytes
Hi all, been having a right nightmare with a callback function that i'm 
trying to code / work with.

I'm using some third-party libraries written in pascal but i have a .h / 
.hpp for them.  I've created a wrapper class to deal with all the aspects of 
using these libraries.  However, one of the functions requires a callback 
procedure.  I need this callback to be able to 'see' my wrapper so i 
declared it thus:

// header
class TInjectController
{
private:
   TCriticalSection *csIPCCallBack;
   static void CALLBACK IPCProcessMsg(char *cName, void *pMsgBuf, unsigned 
int iMsgLen, void *pRtnBuf, unsigned int iRtnLen);
   ...

public:
   ...
   TInjectController();
   ~TInjectController();
};

extern TInjectController *InjectController;

// implimentation
void CALLBACK TInjectController::IPCProcessMsg(char *cName, void *pMsgBuf, 
unsigned int iMsgLen,
                                               void *pRtnBuf, unsigned int 
iRtnLen)
{
   InjectController->csIPCCallBack->Enter();
   ...
   InjectController->csIPCCallBack->Leave();
}

- I've declared the callback function as static and stuck in the extern 
reference at the bottom of the class.  I did this because it's the only way 
that i found that works in the past, with other callbacks i.e. EnumWindows 
etc...

However, on compile i get "[Linker Error] Unresolved external 
'_InjectController' referenced from C:\DOCUMENTS AND 
SETTINGS\ADMINISTRATOR\DESKTOP\TEST 
INJECTOR\TINJECTCONTROLLER\TINJECTCONTROLLER.OBJ"

If i remove the reference to the wrapper from within the callback, it works 
fine - but defeats the object and breaks my design.

Can anyone help me out here?  Also, can anyone tell me why the extern 
reference seems to be necessary >
Technical Details
Message-ID: <46716c33@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!feeder3.cambrium.nl!feeder2.cambrium.nl!feed.tweaknews.nl!xlned.com!feeder1.xlned.com!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,f434271506d1483b
X-Google-Attributes: gid10cc67,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Mike Collins" <its@TheBottomOfThePost>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: CALLBACK Hell
Date: Thu, 14 Jun 2007 17:35:59 -0000
Lines: 56
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.3790.3959
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.4073
NNTP-Posting-Host: 86.145.184.96
Message-ID: <46716c33@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1181838387 86.145.184.96 (14 Jun 2007 09:26:27 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!feeder3.cambrium.nl!feeder2.cambrium.nl!feed.tweaknews.nl!xlned.com!feeder1.xlned.com!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail