Exporting Data from DLL

Everything else that doesn't fall into one of the other PB categories.
FloHimself
Enthusiast
Enthusiast
Posts: 229
Joined: Wed May 14, 2003 3:38 pm
Location: Lüneburg - Germany

Exporting Data from DLL

Post by FloHimself »

Hi,

i want to translate a plugin from C++ to PureBasic.

Is something like "exporting Data from DLL" possible in Purebasic?

This is the C(++) source i want to translate:

Code: Select all

extern "C" __declspec(dllexport) unsigned long  FunctionTable [] =
{
    (DWORD) "Name",
    (DWORD) "Description",
    NULL
};
If i get this right, the compiler translates this to a function returning an array??

See "Using __declspec(dllexport) and __declspec(dllimport) on Data":
http://msdn.microsoft.com/library/defau ... ort.29.asp

Any hints?

Thanks.
Flo
My favorite numbers: 09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0
FloHimself
Enthusiast
Enthusiast
Posts: 229
Joined: Wed May 14, 2003 3:38 pm
Location: Lüneburg - Germany

Post by FloHimself »

i've got this working.
@fred: can you give us an easy way to export data??

this is the purebasic source i used.
compiled this as DLL with the /COMMENTED switch.

Code: Select all

Structure FUNCTIONTABLE
  name.l
  description.l
  terminator.l
EndStructure

Global FunctionTable.FUNCTIONTABLE
Global name$
Global description$

name$ = "a name"
description$ = "a description"
FunctionTable\name = @name$
FunctionTable\description = @description$
FunctionTable\terminator = 0
then i added

Code: Select all

public v_FunctionTable
to the purebasic.asm file and modified the generated purebasic.def to:

Code: Select all

LIBRARY "PureBasic.dll"
EXPORTS
FunctionTable = v_FunctionTable DATA
and recompiled with /REASM.
My favorite numbers: 09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0
Post Reply