有那位知道在vb.net中如何调用delphi写的dll? (50分)

  • 主题发起人 主题发起人 devil_li
  • 开始时间 开始时间
D

devil_li

Unregistered / Unconfirmed
GUEST, unregistred user!
有那位知道在vb.net中如何调用delphi写的dll?
比如这两个函数在Dll中的定义:
procedure SetData(myUsername, myNamespace, myData: PChar;
myPublic: Boolean);
stdcall;
procedure GetData(myUsername, myNamespace: PChar;
Data:PChar);
stdcall;
delphi这样调用:
//先声明:
procedure SetData(myUsername, myNamespace, myData: PChar;
myPublic: Boolean);
stdcall;
procedure GetData(myUsername, myNamespace: PChar;
R: PChar);
stdcall;
//实现:
implementation
{$R *.dfm}
procedure SetData;
external 'JabberData.dll';
procedure GetData;
external 'JabberData.dll';
procedure TForm1.Button1Click(Sender: TObject);
begin
SetData('1', '1', '111', True);
end;

procedure TForm1.Button2Click(Sender: TObject);
var
S: string;
begin
SetLength(S, 100);
FillChar(S[1], 100, 0);
GetData('1', '1', PChar(S));
ShowMessage(PChar(S));
end;

这两个函数如果是VB.NET怎么调用?在什么地方调用?
 
做成COM组件,那什么都可以调用了。
 
看看怎么调APi就行了
和调API没区别!
这是C#的调用方法,你自己看看吧!
[DllImport("gdi32.dll")]
static public extern bool StretchBlt(IntPtr hDCDest, int XOriginDest, int YOriginDest, int WidthDest, int HeightDest,
IntPtr hDCSrc, int XOriginScr, int YOriginSrc, int WidthScr, int HeightScr, uint Rop);
[DllImport("gdi32.dll")]
static public extern IntPtr CreateCompatibleDC(IntPtr hDC);
[DllImport("gdi32.dll")]
static public extern IntPtr CreateCompatibleBitmap(IntPtr hDC, int Width, int Heigth);
[DllImport("gdi32.dll")]
static public extern IntPtr SelectObject(IntPtr hDC, IntPtr hObject);
[DllImport("gdi32.dll")]
static public extern bool BitBlt(IntPtr hDCDest, int XOriginDest, int YOriginDest, int WidthDest, int HeightDest,
IntPtr hDCSrc, int XOriginScr, int YOriginSrc, uint Rop);
[DllImport("gdi32.dll")]
static public extern IntPtr DeleteDC(IntPtr hDC);
 

Similar threads

后退
顶部