Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi Brauche Hilfe bei Übersetzung VB - C - Delphi (https://www.delphipraxis.net/118536-brauche-hilfe-bei-uebersetzung-vbulletin-c-delphi.html)

Wal 9. Aug 2008 22:17


Brauche Hilfe bei Übersetzung VB - C - Delphi
 
Habe hier VB-Source die eine C-Dll aufruft und habe Probleme bei der Übersetzung.
Delphi-Quellcode:
Public Declare Function VB_GetModuleName Lib "USBRadio.dll" (ByVal sNameBuffer As String, ByRef iNameLenght As Integer) As Long

Public Function WVB_GetModuleName() As String
   
    Dim sBuffer   As String * 256
    Dim iBufferLen As Integer
    Dim lRet      As Long
   
    lRet = VB_GetModuleName(sBuffer, iBufferLen)
    If lRet = 0 Then
        WVB_GetModuleName = Left(sBuffer, iBufferLen)
    End If
Übersetzt habe ich es so, aber ich bekomme eine Zugriffsverletzung von der Dll:
Delphi-Quellcode:
TFNVB_GetModuleName     = function(var buf: string; var size: Integer): Integer; stdcall;

var
  iDummy: integer;
  size: integer;
  strDummy: string;
begin
  SetLength(strDummy, 256);
  iDummy := VB_GetModuleName(strDummy, size);
  if IDummy = 0 then
  begin
    LeftStr(strDummy, size);
    OutputDebugString(PChar(strDummy));
  end;
end;
In VB funktioniert der Aufruf, habe ich getestet.

Wal

FAlter 9. Aug 2008 22:36

Re: Brauche Hilfe bei Übersetzung VB - C - Delphi
 
Hi,

schonmal mit PChar statt String probiert, und das var weg (ByVal, nicht ByRef)?

Und Integer <--> Long? Weiß ja nicht wie das in VB ist, aber es könnte auch einmal int64 gemeint sein.

Mfg
FAlter

Wal 9. Aug 2008 23:20

Re: Brauche Hilfe bei Übersetzung VB - C - Delphi
 
Zitat:

Zitat von FAlter
Hi,

schonmal mit PChar statt String probiert, und das var weg (ByVal, nicht ByRef)?

Und Integer <--> Long? Weiß ja nicht wie das in VB ist, aber es könnte auch einmal int64 gemeint sein.

Mfg
FAlter

Danke,
das var vor buf war's und ich mach stundenlang rum. :oops:

Wal


Alle Zeitangaben in WEZ +1. Es ist jetzt 19:42 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