Page 1 of 1

Exporting Data from DLL

Posted: Sat Aug 06, 2005 5:53 am
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

Posted: Wed Aug 24, 2005 11:37 am
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.