Re: Using Dll created with Delphi in Excel
- From: Jamie <jamie_ka1lpa_not_valid_after_ka1lpa_@xxxxxxxxxxx>
- Date: Sat, 15 Mar 2008 21:44:07 -0500
hasu wrote:
Hi all,You must declare the Exported function in the DLL as STDCALL.
Delphi's Dll:
library ProjektiList;
type
...
function GetProjectText(Nro:Integer):String;
function GetProjectText(Nro:Integer):String;
begin
...
Showmessage(IntToStr(Nro));
result:='Hello?!'
end;
Excel macro:
Private Declare Function GetProjectText Lib "ProjektiList.dll" _
(ByVal nProNro As Integer) As String
Private Const nProNro = 7223
Public Function GetProjectName() As String
ActiveCell.Value = GetProjectText(nProNro )
End Function
It does not work! Showmessage shows something totally different than 7223.
And after excel crashes...
Program versions; Delphi = 2006, Excel = 2007
Does anyone has simple enough example even for me to understand?
-Hasu
also, Delphi native string is not compatible with other lauguages.
I'm sure that language uses Double wide characters..
try passing back a PWideChar instead..
Var
SomeGlobelString:Widestring;
Function MydllCall(SomeINteger:Integer):PWideChar;Stdcall;
Begin
SomeGlobelString := 'What the Crap';
result := PWidechar(SomeBlobelString);
End;
http://webpages.charter.net/jamie_5"
.
- References:
- Using Dll created with Delphi in Excel
- From: hasu
- Using Dll created with Delphi in Excel
- Prev by Date: Re: Delphi is evil
- Next by Date: Pb de debogage
- Previous by thread: Using Dll created with Delphi in Excel
- Next by thread: Pb de debogage
- Index(es):