AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Programmieren allgemein Hilfe bei Delphi wrapper für DLL - C/C++ Header
Thema durchsuchen
Ansicht
Themen-Optionen

Hilfe bei Delphi wrapper für DLL - C/C++ Header

Ein Thema von axellang · begonnen am 14. Okt 2008 · letzter Beitrag vom 16. Okt 2008
Antwort Antwort
axellang

Registriert seit: 3. Mai 2003
Ort: München
138 Beiträge
 
Delphi XE2 Enterprise
 
#1

Hilfe bei Delphi wrapper für DLL - C/C++ Header

  Alt 14. Okt 2008, 23:08
Hallo Leute,

vielleicht kann mir jemand bei meinem Problem helfen. Ich habe mir von Skyhook Wireless die SDK heruntergeladen
und einen Delphi Wrapper geschrieben da ich den Dienst in einem Delphi Programm verwenden möchte. Leider habe ich Probleme auf bestimmte Rückgabewerte der DLL zuzugreifen.

Bevor ich jetzt das Problem genau beschreibe, würde es mir schon sehr helfen, wenn einer von den hier mitlesenden C/C++ Profis, sich mal die Delphi Unit zu Gemüte
führt um evtl. Fehler bei der Übersetzung zu berichtigen.

Die originale header Datei habe ich als Attachment eingefügt da ich keine Ahnung habe ob man die so einfach veröffentlichen darf obwohl das SDK nach Anmeldung
kostenlos herunterzuladen ist.

Wrapper für wpsapi.h:

Delphi-Quellcode:
unit wpsapi;

interface

uses
  Windows;
  
type

  PWPSReturnCode = ^TWPSReturnCode;
  WPS_ReturnCode = (
    WPS_OK = 0,
    WPS_ERROR_SCANNER_NOT_FOUND = 1,
    WPS_ERROR_WIFI_NOT_AVAILABLE = 2,
    WPS_ERROR_NO_WIFI_IN_RANGE = 3,
    WPS_ERROR_UNAUTHORIZED = 4,
    WPS_ERROR_SERVER_UNAVAILABLE = 5,
    WPS_ERROR_LOCATION_CANNOT_BE_DETERMINED = 6,
    WPS_ERROR_PROXY_UNAUTHORIZED = 7,
    WPS_ERROR_FILE_IO = 8,
    WPS_ERROR_INVALID_FILE_FORMAT = 9,
    WPS_NOMEM = 98,
    WPS_ERROR = 99
  );
  TWPSReturnCode = WPS_ReturnCode;


  PWPSContinuation = ^TWPSContinuation;
  WPS_Continuation = (
    WPS_STOP = 0,
    WPS_CONTINUE = 1
  );
  TWPSContinuation = WPS_Continuation;


  PWPSSimpleAuthentication = ^TWPSSimpleAuthentication;
  WPS_SimpleAuthentication = record
   username: PChar;
   realm: PChar;
  end;
  TWPSSimpleAuthentication = WPS_SimpleAuthentication;


  PWPSStreetAddressLookup = ^TWPSStreetAddressLookup;
  WPS_StreetAddressLookup = (
   WPS_NO_STREET_ADDRESS_LOOKUP,
   WPS_LIMITED_STREET_ADDRESS_LOOKUP,
   WPS_FULL_STREET_ADDRESS_LOOKUP
  );
  TWPSStreetAddressLookup = WPS_StreetAddressLookup;


  PWPSNameCode = ^TWPSNameCode;
  WPS_NameCode = record
   name: PChar;
   code: array[0..2] of Char;
  end;
  TWPSNameCode = WPS_NameCode;


  PWPSStreetAddress = ^TWPSStreetAddress;
  WPS_StreetAddress = record
   street_number: PChar;
   address_line: PPChar;
   city: PChar;
   postal_code: PChar;
   county: PChar;
   province: PChar;
   state: WPS_NameCode;
   region: PChar;
   country: WPS_NameCode;
  end;
  TWPSStreetAddress = WPS_StreetAddress;


  PWPSLocation = ^TWPSLocation;
  WPS_Location = record
   latitude: Double;
   longitude: Double;
   hpe: Double;
   nap: Word;
   speed: Double;
   bearing: Double;
   street_address: WPS_StreetAddress;
  end;
  TWPSLocation = WPS_Location;


  PWPSIPLocation = ^TWPSIPLocation;
  WPS_IPLocation = record
   ip: PChar;
   latitude: Double;
   longitude: Double;
   street_address: WPS_StreetAddress;
  end;
  TWPSIPLocation = WPS_IPLocation;



 type

 WPS_LocationCallback = function (arg:pointer; code:WPS_ReturnCode; location: WPS_Location):WPS_Continuation; cdecl;
 WPS_TilingCallback = function(arg:pointer; tileNumber:dword; tileTotal:dword): WPS_Continuation; cdecl;


 //*************************************************************************************************************

var

  XWPS_location : function(var authentication: WPS_SimpleAuthentication; street_address_lookup: WPS_StreetAddressLookup; var location: WPS_Location): WPS_ReturnCode; cdecl;
  WPS_periodic_location : function(var authentication: WPS_SimpleAuthentication;street_address_lookup: WPS_StreetAddressLookup;period: Longword;iterations: Cardinal;callback:
  WPS_LocationCallback; arg: Pointer): WPS_ReturnCode; cdecl;
  WPS_ip_location : function(var authentication: WPS_SimpleAuthentication;street_address_lookup: WPS_StreetAddressLookup;var location: WPS_IPLocation): WPS_ReturnCode; cdecl; WPS_free_location : procedure(_para1:WPS_Location);cdecl;
  WPS_free_ip_location : procedure(_para1:WPS_IPLocation);cdecl;
  WPS_set_proxy : procedure(address: PChar;port: Integer;user: PChar; password: PChar); cdecl;
  WPS_set_server_url : procedure(url: PChar); cdecl;
  WPS_set_user_agent : procedure(ua: PChar); cdecl;
  WPS_set_local_files_path :function(var paths: PChar): WPS_ReturnCode; cdecl;
  WPS_set_tier2_area : function(dirpath: PChar; size: Cardinal): WPS_ReturnCode; cdecl;
  WPS_tiling : function(dirpath: PChar;maxDataSizePerSession: Cardinal;maxDataSizeTotal: Cardinal;callback: WPS_TilingCallback;param: Pointer): WPS_ReturnCode; cdecl;
  WPS_register_user : function(var authentication: WPS_SimpleAuthentication;var new_authentication: WPS_SimpleAuthentication): WPS_ReturnCode; cdecl;

   SkyHook_Handle : Thandle = 0;

    function Load_SkyHook(const dllfilename : string) : boolean;
    procedure Unload_SkyHook;

implementation

function Load_SkyHook(const dllfilename : string) : boolean;
var
   oldmode : integer;
begin
   if SkyHook_Handle <> 0 then
      result := true
   else begin
     oldmode := SetErrorMode($8001);
     SkyHook_Handle := LoadLibrary(pchar(dllfilename));
     SetErrorMode(oldmode);

   if SkyHook_Handle <> 0 then
      begin
        @XWPS_location := GetProcAddress(SkyHook_Handle,'WPS_location');
        @WPS_periodic_location := GetProcAddress(SkyHook_Handle,'WPS_periodic_location');
        @WPS_ip_location := GetProcAddress(SkyHook_Handle,'WPS_ip_location');
        @WPS_free_location := GetProcAddress(SkyHook_Handle,'WPS_free_location');
        @WPS_free_ip_location := GetProcAddress(SkyHook_Handle,'WPS_free_ip_location');
        @WPS_set_proxy := GetProcAddress(SkyHook_Handle,'WPS_set_proxy');
        @WPS_set_server_url := GetProcAddress(SkyHook_Handle,'WPS_set_server_url');
        @WPS_set_user_agent := GetProcAddress(SkyHook_Handle,'WPS_set_user_agent');
        @WPS_set_local_files_path := GetProcAddress(SkyHook_Handle,'WPS_set_local_files_path');
        @WPS_set_tier2_area := GetProcAddress(SkyHook_Handle,'WPS_set_tier2_area');
        @WPS_tiling := GetProcAddress(SkyHook_Handle,'WPS_tiling');
        @WPS_register_user := GetProcAddress(SkyHook_Handle,'WPS_register_user');


      if (@XWPS_location = nil) or
          (@WPS_periodic_location = nil) or
          (@WPS_ip_location = nil) or
          (@WPS_free_location = nil) or
          (@WPS_free_ip_location = nil) or
          (@WPS_set_proxy = nil) or
          (@WPS_set_server_url = nil) or
          (@WPS_set_user_agent = nil) or
          (@WPS_set_local_files_path = nil) or
          (@WPS_set_tier2_area = nil) or
          (@WPS_tiling = nil) or
          (@WPS_register_user = nil) then


           begin
              FreeLibrary(SkyHook_Handle);
              SkyHook_Handle := 0;
           end;
      end;
        result := (SkyHook_Handle <> 0);
   end;
end;

procedure Unload_SkyHook;
begin
   if SkyHook_Handle <> 0 then
   FreeLibrary(SkyHook_Handle);
   SkyHook_Handle := 0;
end;

end.

Gruß

Axel
Angehängte Dateien
Dateityp: rar wpsapi_wrapper_578.rar (8,5 KB, 7x aufgerufen)
Alexander Lang
  Mit Zitat antworten Zitat
Benutzerbild von nicodex
nicodex

Registriert seit: 2. Jan 2008
Ort: Darmstadt
286 Beiträge
 
Delphi 2007 Professional
 
#2

Re: Hilfe bei Delphi wrapper für DLL - C/C++ Header

  Alt 16. Okt 2008, 09:35
Wenn ich es in fünf Minuten übersetzen hätte müssen, dann würde es so aussehen
(siehe Anhang)
Angehängte Dateien
Dateityp: zip wpsapi27_111.zip (1,4 KB, 25x aufgerufen)
  Mit Zitat antworten Zitat
axellang

Registriert seit: 3. Mai 2003
Ort: München
138 Beiträge
 
Delphi XE2 Enterprise
 
#3

Re: Hilfe bei Delphi wrapper für DLL - C/C++ Header

  Alt 16. Okt 2008, 11:59
Hi nicodex,

Zitat von nicodex:
Wenn ich es in fünf Minuten übersetzen hätte müssen, dann würde es so aussehen
(siehe Anhang)
das waren aber die richtigen 5 Minuten . Muss noch mal alles durchtesten und gebe Dir bescheid.

Danke

Axel
Alexander Lang
  Mit Zitat antworten Zitat
Antwort Antwort


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 08:45 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