ByVal/ByRef confusion with strings
From: Mike McWhinney (eljainc_at_ameritech.net)
Date: 01/23/04
- Next message: Patrice Rabiller: "Re: [D4]Text files and mac-osx+Virtual PC"
- Previous message: Rick Carter: "Re: Problems getting hourglass to work correctly"
- Next in thread: Rob Kennedy: "Re: ByVal/ByRef confusion with strings"
- Reply: Rob Kennedy: "Re: ByVal/ByRef confusion with strings"
- Reply: Jeremy Collins: "Re: ByVal/ByRef confusion with strings"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 22 Jan 2004 21:23:54 -0800
Hello,
I am converting some VB code into Delphi 5.0. I have
come across a construct such as:
Public Declare Function USBm_DeviceVID Lib "USBm.dll"
(ByVal device As Byte) As Integer
This would translate to the following equivalent in Delphi:
Function USBm_DeviceVID(device:Byte):smallInt; stdcall; external
'USBm.dll'
However when I get to the following:
Function USBm_RecentError Lib "USBm.dll"
(ByVal errorstring As String) As Integer
I would tend to write this as:
Function USBm_RecentError(errorstring:widestring):smallint; stdcall;
external 'USBm.dll'
However, in the function description it says that 'errorstring' is
returned
with the value of the error. Shouldn't ByVal be ByRef instead in the
previous function? Or should the Delphi function have a var
parameter.
I understand that string parameters are passed as pointers in VB.
Could someone please clear this up for me?
Thanks.
Mike McWhinney
- Next message: Patrice Rabiller: "Re: [D4]Text files and mac-osx+Virtual PC"
- Previous message: Rick Carter: "Re: Problems getting hourglass to work correctly"
- Next in thread: Rob Kennedy: "Re: ByVal/ByRef confusion with strings"
- Reply: Rob Kennedy: "Re: ByVal/ByRef confusion with strings"
- Reply: Jeremy Collins: "Re: ByVal/ByRef confusion with strings"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|