I'm not sure why you attempted to use a variant to pass a string. It seems to me to be more sensible to pass a string. Do this by:
- Changing the VBA
Declare
statement to specify the parameter type to beByVal par As String
. - Changing the Delphi parameter from
PChar
toPAnsiChar
. For your Unicode DelphiPChar
is an alias toPWideChar
.
As an aside, do note that the Delphi export
directive is ignored. You should remove it.