🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
3 messages
3 total messages Started by Victor G. Baron Fri, 18 Apr 2003 15:33
Dll conversion
#16880
Author: Victor G. Baron
Date: Fri, 18 Apr 2003 15:33
159 lines
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.
Re: Dll conversion
#16886
Author: Victor G. Baron
Date: Fri, 18 Apr 2003 21:34
13 lines
1385 bytes
Resolved one issue - the multiple declarations are no longer an issue. Had
included the H file in the project along with it's being included in the C
module.

Still need help with the other areas.

Thank you,

Vic
-- 
Vic Baron
I haven't lost my mind, it's backed up on disk somewhere!
UPDATE!!-- I have lost my mind.
Re: Dll conversion
#16902
Author: Greg Brewer
Date: Sun, 20 Apr 2003 04:30
208 lines
5198 bytes
Your problem is
// These are the two structs that are exported from the DLL
//
typedef struct IMPORTTABLE
{
    struct
    {
        ID fnID;
        PVOID fnPtr;
    } dummy;
} IMPORTTABLE;

You have defined a typedef named IMPORTTABLE and a struct named IMPORTTABLE;
apparently MSVC6 doesn't consider it a problem.  I would suggest you change
it to either
// These are the two structs that are exported from the DLL
//
typedef struct IMPORT_TABLE
{
    struct
    {
        ID fnID;
        PVOID fnPtr;
    } dummy;
} IMPORTTABLE;

or better yet
// These are the two structs that are exported from the DLL
//
struct IMPORTTABLE
{
    struct
    {
        ID fnID;
        PVOID fnPtr;
    } dummy;
};

same for the other duplicate.



"Victor G. Baron" <vgbaron@hotmail.com> wrote in message
news:8060av8s89u8f5k4ujv19bfoh4nd4j5315@4ax.com...
> 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.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads