VC调用Delphi制作的动态链接库如何互相传递字符串
来源:互联网 发布:php imagepng 编辑:程序博客网 时间:2024/05/22 05:23
1、VC to Delphi
Delphi源程序:
library ExportChartData;
uses
SysUtils,
Classes;
{$R *.res}
const
DLL_VER : Word = $0001;
function GetVer: Word;
begin
Result := DLL_VER;
end;
procedure SayHello(aString:pchar);cdecl;
begin
if aString = 'Hello!' then Beep;
end;
exports
GetVer,
SayHello;
begin
end.
uses
SysUtils,
Classes;
{$R *.res}
const
DLL_VER : Word = $0001;
function GetVer: Word;
begin
Result := DLL_VER;
end;
procedure SayHello(aString:pchar);cdecl;
begin
if aString = 'Hello!' then Beep;
end;
exports
GetVer,
SayHello;
begin
end.
VC源程序
// TestInterface.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <windows.h>
int main(int argc, char* argv[])
{
char *szDllName = "..\\..\\OBJ\\ExportChartData.dll";
HINSTANCE hInstance = LoadLibrary(szDllName);
if (hInstance != NULL)
{
void (*f)(char &) = (void (*)(char &))GetProcAddress(hInstance, "SayHello");
char *s = "Hello!";
f(*s);
}
FreeLibrary(hInstance);
return 0;
}
//
#include "stdafx.h"
#include <windows.h>
int main(int argc, char* argv[])
{
char *szDllName = "..\\..\\OBJ\\ExportChartData.dll";
HINSTANCE hInstance = LoadLibrary(szDllName);
if (hInstance != NULL)
{
void (*f)(char &) = (void (*)(char &))GetProcAddress(hInstance, "SayHello");
char *s = "Hello!";
f(*s);
}
FreeLibrary(hInstance);
return 0;
}
2、Delphi to VC
Delphi源程序
library ExportChartData;
uses
SysUtils,
Classes;
{$R *.res}
const
DLL_VER : Word = $0001;
function GetVer: Word;
begin
Result := DLL_VER;
end;
procedure SayHello(index:Integer;aString:pchar);cdecl;
begin
if index = 0 then strcopy(aString,'A Test for Pass String!')
else
strcopy(aString,'OK!');
end;
exports
GetVer,
SayHello;
begin
end.
uses
SysUtils,
Classes;
{$R *.res}
const
DLL_VER : Word = $0001;
function GetVer: Word;
begin
Result := DLL_VER;
end;
procedure SayHello(index:Integer;aString:pchar);cdecl;
begin
if index = 0 then strcopy(aString,'A Test for Pass String!')
else
strcopy(aString,'OK!');
end;
exports
GetVer,
SayHello;
begin
end.
VC源程序
// TestInterface.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <windows.h>
#include <stdio.h>
typedef char* PCHAR;
int main(int argc, char* argv[])
{
PCHAR szDllName = "..\\..\\OBJ\\ExportChartData.dll";
HINSTANCE hInstance = LoadLibrary(szDllName);
char *s = new char[255];
if (hInstance != NULL)
{
void (*f)(int, char *) = (void (*)(int, char *))GetProcAddress(hInstance, "SayHello");
f(1, s);
printf("%s",s);
}
FreeLibrary(hInstance);
delete[]s;
return 0;
}
//
#include "stdafx.h"
#include <windows.h>
#include <stdio.h>
typedef char* PCHAR;
int main(int argc, char* argv[])
{
PCHAR szDllName = "..\\..\\OBJ\\ExportChartData.dll";
HINSTANCE hInstance = LoadLibrary(szDllName);
char *s = new char[255];
if (hInstance != NULL)
{
void (*f)(int, char *) = (void (*)(int, char *))GetProcAddress(hInstance, "SayHello");
f(1, s);
printf("%s",s);
}
FreeLibrary(hInstance);
delete[]s;
return 0;
}
0 0
- VC调用Delphi制作的动态链接库如何互相传递字符串
- VC与Delphi之间动态链接库互相调用
- VC与Delphi之间动态链接库互相调用
- Delphi中如何调用VC++创建的动态链接库
- vc和delphi之间动态链接库互相调用_delphi教程
- Delphi中如何调用VC++创建的动态链接库(zhuan)
- Delphi中怎么调用VC++创建的动态链接库
- Delphi中怎么调用VC++创建的动态链接库
- Delphi中怎么调用VC++创建的动态链接库
- VC++和C++builder互相调用动态链接库DLL(VC++编的)笔记
- c#中如何调用vc++写的动态链接库
- 在Delphi中调用VC++创建的动态链接库的Demo
- 在Delphi中调用VC++创建的动态链接库的实例
- 动态链接库的制作与调用
- 动态链接库的制作与调用
- VC调用动态链接库的错误
- VC++ 6.0如何创建与调用动态链接库
- VC++ 6.0如何创建与调用动态链接库
- 学习Java以及Android开发一段时间后对面向对象的理解
- RoHS
- <云架构 大数据 JAVA网贷平台开发>深圳市金橙尔商务有限公司
- 一点儿Git使用心得(一)
- UVALive 6117 (LA 6117) Pole Arrangement 动态规划
- VC调用Delphi制作的动态链接库如何互相传递字符串
- 移动应用隐私政策
- 新手记录 自学cocos2dx 之 TextFieldTTF
- 类型转换
- [hdu 4896]14多校J题 Minimal Spanning Tree 打表
- Android学习笔记(二)---Mediaplayer、关于视频,音频,录像,录音
- android中layout_weight的理解
- PrintJ的设计模式之旅——1.模式之父
- GO与Java的DES ECB加解密算法互换