AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Problem mit C++ DLL mit Stringfunktionen

Ein Thema von Blink · begonnen am 31. Okt 2008 · letzter Beitrag vom 11. Nov 2008
 
Benutzerbild von Blink
Blink

Registriert seit: 10. Apr 2007
Ort: Hamburg
169 Beiträge
 
Turbo Delphi für Win32
 
#1

Problem mit C++ DLL mit Stringfunktionen

  Alt 31. Okt 2008, 17:09
Hallo DPler,

ich versuche schon seit ein paar Tagen Funktionen aus einer C++ DLL zu nutzen, leider hab ich das bis her noch nicht hinbekommen, da einige Funktionen in der DLL Strings als Argumente erwarten.
Ich hoffe ihr könnt mir sagen was ich falsch mache oder wie ich es machen muss damit es funktioniert.

Hier mein Delphi Code:

Delphi-Quellcode:
unit Unit1;

interface



uses
  Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ShareMem;

  function ohs_set_password(PW: string): Double; stdcall;
  function ohs_get_status: Double; stdcall;
  function ohs_get_position: Double; stdcall;
  function ohs_table_clear: Double; stdcall;
  function ohs_table_update: Double; stdcall;
  function ohs_table_get(Spalte: Double; Reihe: Double): string; stdcall;
  function ohs_header_get(Spalte: Double): string; stdcall;
  function ohs_table_columns: Double; stdcall;
  function ohs_table_rows: Double; stdcall;
  function ohs_submit_add(Spalte: Double; Wert: string): Double; stdcall;
  function ohs_submit_clear: Double; stdcall;
  function ohs_set_url(URL: string; Pfad: string): Double; stdcall;
  function ohs_set_table(Tabelle: string): Double; stdcall;
type
  TForm1 = class(TForm)
    Button1: TButton;
    Label1: TLabel;
    Label2: TLabel;
    procedure Button1Click(Sender: TObject);
  private
    { Private-Deklarationen }

  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

function ohs_set_password(PW: string): Double; stdcall;
external 'ohs.dll';

function ohs_get_status: Double; stdcall;
external 'ohs.dll';

function ohs_get_position: Double; stdcall;
external 'ohs.dll';

function ohs_table_clear: Double; stdcall;
external 'ohs.dll';

function ohs_table_update: Double; stdcall;
external 'ohs.dll';

function ohs_table_get(Spalte: Double; Reihe: Double): string; stdcall;
external 'ohs.dll';

function ohs_header_get(Spalte: Double): string; stdcall;
external 'ohs.dll';

function ohs_table_columns: Double; stdcall;
external 'ohs.dll';

function ohs_table_rows: Double; stdcall;
external 'ohs.dll';

function ohs_submit_add(Spalte: Double; Wert: string): Double; stdcall;
external 'ohs.dll';

function ohs_submit_clear: Double; stdcall;
external 'ohs.dll';

function ohs_set_url(URL: string; Pfad: string): Double; stdcall;
external 'ohs.dll';

function ohs_set_table(Tabelle: string): Double; stdcall;
external 'ohs.dll';

procedure TForm1.Button1Click(Sender: TObject);
begin
  ohs_set_url(PChar('http://muti.mu.funpic.de'), PChar('/OHS'));
  ohs_set_table(PChar('TEST'));
  ohs_set_password(Pchar('12345'));

  Label1.Caption:= FloatToStr(ohs_table_update);

  ohs_submit_add(0, PChar('Test'));
  ohs_submit_add(1, PChar('300'));


  Label1.Caption:= FloatToStr(ohs_table_update);
  Label2.Caption:= FloatToStr(ohs_get_position);
end;
So deklariert der Autor der DLL die Funktionen im GM:

Code:
#define ohs_init
global.dll_ohs_set_password = external_define("ohs.dll","ohs_set_password",dll_stdcall,ty_real,1,ty_string);
global.dll_ohs_set_url = external_define("ohs.dll","ohs_set_url",dll_stdcall,ty_real,2,ty_string,ty_string);
global.dll_ohs_set_table = external_define("ohs.dll","ohs_set_table",dll_stdcall,ty_real,1,ty_string);
global.dll_ohs_get_status = external_define("ohs.dll","ohs_get_status",dll_stdcall,ty_real,0);
global.dll_ohs_get_position = external_define("ohs.dll","ohs_get_position",dll_stdcall,ty_real,0);
global.dll_ohs_table_clear = external_define("ohs.dll","ohs_table_clear",dll_stdcall,ty_real,0);
global.dll_ohs_table_update = external_define("ohs.dll","ohs_table_update",dll_stdcall,ty_real,0);
global.dll_ohs_table_get = external_define("ohs.dll","ohs_table_get",dll_stdcall,ty_string,2,ty_real,ty_real);
global.dll_ohs_header_get = external_define("ohs.dll","ohs_header_get",dll_stdcall,ty_string,1,ty_real);
global.dll_ohs_table_columns = external_define("ohs.dll","ohs_table_columns",dll_stdcall,ty_real,0);
global.dll_ohs_table_rows = external_define("ohs.dll","ohs_table_rows",dll_stdcall,ty_real,0);
global.dll_ohs_submit_add = external_define("ohs.dll","ohs_submit_add",dll_stdcall,ty_real,2,ty_real,ty_string);
global.dll_ohs_submit_clear = external_define("ohs.dll","ohs_submit_clear",dll_stdcall,ty_real,0);
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 03:34 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz