Article View: borland.public.cppbuilder.nativeapi
Article #16880Dll conversion
From: Victor G. Baron
Date: Fri, 18 Apr 2003 15:33
Date: Fri, 18 Apr 2003 15:33
159 lines
4087 bytes
4087 bytes
Hi -
The following code compiles in MSVC6 and creates a DLL that is loaded by another
program. I need help doing several things -
1) get it to compile in BCB5
2) Set a system hook for the keyboard
3) Display a form from within the dll
#2 I can figure out but when I try to compile in BCB5 I get an error " Multiple
declaration for LINKAGE" and the same for IMPORT TABLE.
How do I get by this?
And most important, can I use VCL to create the form and then how to display?
Any help appreciated.
Vic Baron
<------------------code--------->
//FSMODULE.H
//
// Example Microsoft Flight Simulator 2002 Module
//
// Copyright 2001-2002 Joel M. DeYoung
// This code may be freely distributed and modified provided this notice
// remains unchanged.
//
// This is the minimal amount of code required to get Microsoft Flight Simulator
// to load a DLL that is placed in the modules subdirectory under the main
// FS directory.
//
#ifndef FSMODULE_H_
#define FSMODULE_H_
#include <windows.h>
// We must specify this alignment directive
//
#pragma pack(4)
// Some defines
//
typedef int ID;
typedef unsigned int VAR32;
typedef VAR32 FLAGS32;
#define FSAPI __stdcall
// These are the functions called when loading and unloading the module
//
extern void FSAPI module_init ();
extern void FSAPI module_deinit ();
// These are the two structs that are exported from the DLL
//
typedef struct IMPORTTABLE
{
struct
{
ID fnID;
PVOID fnPtr;
} dummy;
} IMPORTTABLE;
__declspec (dllexport) IMPORTTABLE ImportTable;
typedef struct LINKAGE
{
ID ModuleID;
void (FSAPI *ModuleInit) ();
void (FSAPI *ModuleDeInit) ();
FLAGS32 ModuleFlags;
UINT32 ModulePriority;
UINT32 ModuleVersion;
LPVOID* Table[];
} LINKAGE;
__declspec (dllexport) LINKAGE Linkage;
#pragma pack ()
#endif
<--------------c file code-------------------->
//FSMODULE.C
//
// Example Micosoft Flight Simulator 2002 Module
//
// Copyright 2001-2002 Joel M. DeYoung
// This code may be freely distributed and modified provided this notice
// remains unchanged.
//
// This is the minimal amount of code required to get Microsoft Flight Simulator
// to load a DLL that is placed in the modules subdirectory under the main
// FS directory.
//
#include "fsmodule.h"
#include <windows.h>
// The global exported LINKAGE object
//
LINKAGE Linkage =
{
0x000002d9,
module_init,
module_deinit,
0,
0,
0x800,
{ 0 }
};
// The global exported IMPORTTABLE object
//
IMPORTTABLE ImportTable =
{
{
0x00000000, NULL
}
};
// This function is called by MSFS when the module is initialized
//
void FSAPI module_init ()
{
// I need to display the window here
}
// This function is called by MSFS when the module is unloaded
//
void FSAPI module_deinit ()
{
}
--
Vic Baron
I haven't lost my mind, it's backed up on disk somewhere!
UPDATE!!-- I have lost my mind.
Technical Details
Message-ID:
<8060av8s89u8f5k4ujv19bfoh4nd4j5315@4ax.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-06!sn-xit-08!supernews.com!38.144.126.75.MISMATCH!feed1.newsreader.com!newsreader.com!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.frii.net!newsfeed.frii.net!news.compaq.com!uunet!sac.uu.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,5220fd881ef8912f,start X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-04-18 08:33:58 PST From: Victor G. Baron <vgbaron@hotmail.com> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Dll conversion Date: Fri, 18 Apr 2003 08:33:31 -0700 Message-ID: <8060av8s89u8f5k4ujv19bfoh4nd4j5315@4ax.com> X-Newsreader: Forte Agent 1.9/32.560 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 64.175.210.162 X-Trace: newsgroups.borland.com 1050679976 64.175.210.162 (18 Apr 2003 08:32:56 -0700) Lines: 159 Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-06!sn-xit-08!supernews.com!38.144.126.75.MISMATCH!feed1.newsreader.com!newsreader.com!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.frii.net!newsfeed.frii.net!news.compaq.com!uunet!sac.uu.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail