Hi Friends
Hi Friends,
I need to ask two questions here
1. I created DLL using delphi 2006 and register it using regsvr32 but its not shown in COM tab while adding reference in c# studio and i check register dlls as well, my dll is not register in that list. regsvr32 return success message for registration. and when i am trying to add by briwse then it fire error of not valid assembly.
2. I am trying to consume Delphi dll in c# project below is its example. but when parameter value pass from c# in string format and delphi function also used string data type to retrieve parameter value but in dll it get only null value, i tried to use pchar type as well but it accept some garbage value. does i am doing anything wrong? please check below code example and suggest me to do correct.
Delphi
====
Function CallAuthentication(pstrUser, pstrPass: PChar):boolean;
or
Function CallAuthentication(pstrUser, pstrPass: string):boolean;
begin
//code
end;
Exports CallAuthentication;
c#
=========
[DllImport("IntegrationDLL.dll", EntryPoint = "CallAuthentication",CharSet = CharSet.Ansi,
ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
static extern bool CallAuthentication([MarshalAs(UnmanagedType.BStr)] string pstrUser, [MarshalAs(UnmanagedType.BStr)] string pstrPass);
private void button1_Click(object sender, EventArgs e)
{
bool Result;
Result=CallAuthentication("jpb","");
}
I need to ask two questions here
1. I created DLL using delphi 2006 and register it using regsvr32 but its not shown in COM tab while adding reference in c# studio and i check register dlls as well, my dll is not register in that list. regsvr32 return success message for registration. and when i am trying to add by briwse then it fire error of not valid assembly.
2. I am trying to consume Delphi dll in c# project below is its example. but when parameter value pass from c# in string format and delphi function also used string data type to retrieve parameter value but in dll it get only null value, i tried to use pchar type as well but it accept some garbage value. does i am doing anything wrong? please check below code example and suggest me to do correct.
Delphi
====
Function CallAuthentication(pstrUser, pstrPass: PChar):boolean;
or
Function CallAuthentication(pstrUser, pstrPass: string):boolean;
begin
//code
end;
Exports CallAuthentication;
c#
=========
[DllImport("IntegrationDLL.dll", EntryPoint = "CallAuthentication",CharSet = CharSet.Ansi,
ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
static extern bool CallAuthentication([MarshalAs(UnmanagedType.BStr)] string pstrUser, [MarshalAs(UnmanagedType.BStr)] string pstrPass);
private void button1_Click(object sender, EventArgs e)
{
bool Result;
Result=CallAuthentication("jpb","");
}
Comments
Post a Comment