我遇到了一个难解的问题
三种调用方式,一写好DLL程序后,由主程序静态调用DLL
二写好DLL程序后,由Loadlibrary() GetProcaddress() Freelibrary
这三个API完成,我的代码如下:
unit pro1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TInstr = Function(Source:PChar;Check:Char):integer; //为了强制函数类型转换的类型说明
TForm1 = class(TForm)
Edit1: TEdit;
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
// function InStr1(S:PChar;Check:Char):integer; far; external'D:\DLLself\DLLSelf1.dll';
implementation
{$R *.dfm}
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
var
order:integer;
txt:PChar;
PFunc:TFarProc; //
Moudule:THandle; //句柄
begin
Moudule:=loadlibrary('D:\DLLSelf\DLLSelf1.dll'); //动态连接库路径\文件正确阿!
showmessage(inttostr(Moudule)); //程序执行后 Moudule=13500416
if Moudule>32 then
begin
PFunc:=nil; //先赋空值
PFunc:=GetProcAddress(Moudule,'InStr1'); // InStr1 为动态连接库中的函数名
if PFunc=nil then //若找到函数的入口地址成功那么 PFun必<>nil
begin
showmessage('sss'); //可悲的是此行程序运行了,而且终止了后面真正调用程序的代码了
exit;
end;
txt:=StrAlloc(80); //这往后的代码由于入口地址不对,我永远也执行不了!!!!!
txt:=StrPCopy(txt,Edit1.Text);
order:=TInstr(PFunc)(txt,Key);
if order=-1 then
showmessage('successful')
else
showmessage('unsuccessful');
end;
Freelibrary(Moudule);
end;
end.
/******以上是我的调用动态连接库的程序************/
/**********下面是我编写的动态连接库程序**********/
library DLLSelf1;
{ Important note about DLL memory management: ShareMem must be the
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }
uses
ShareMem,
SysUtils,
Classes;
{$R *.res}
function InStr1(SourceStr:PChar;Ch:Char):integer;export;
var
Len,i:integer;
begin
Len:=strlen(SourceStr);
for i:=0 to Len-1 do
if SourceStr[i]=ch then
begin
Result:=i;
Exit;
end;
Result:=-1;
end;
exports
InStr1 Index 1 name 'MyInStr' resident;
begin
end. //这几行代码想来各位大虾能够知道我的用意:就是想作一个普通的动态库函数被其他程序所用
可是就是不能正常运行. 程序出错为: external exception C30000D 还有,您不介意的话利用我的动态连接
库作一个静态连接调用,和动态连接调用让我大饱眼福,不胜感激阿!!!!!!!谢谢!!!!!!!
相关推荐
暴风影音BHD转MP4格式转换软件
暴风影音下载下来的BHD格式文件,用这个软件可以转换成MP4的,这样就可以用一般的MP4播放器播放了。
暴风影音三
暴风影音3版本建议喜欢的下载。可以先装3然后装最新版来解决解码器问题。
暴风转码1.2,免费好用的万能格式转换工具
暴风转码1.2,免费好用的万能格式转换工具。暴风影音出版。
影音文件转MP4格式文件
将常见的各种格式的影音文件转换为 MP4格式。超级 MP4格式转换器。
YOLO26算法煤气罐识别+训练好的模型+417张数据集+pyqt可视化界面.zip
附训练好的 YOLO 权重与 PyQt 可视化检测界面,页面底部含可视化效果预览,毕设/课设开箱即用。 【数据集概况】 · 检测类别(中文):[()] 【训练曲线与评估图】 【模型训练配置】 参数 | 值 模型 | yolo26n 训练轮数 | 100 epochs 输入尺寸 | 640x640 批次大小 | 24 优化器 | auto 初始学习率 | 0.01 训练设备 【关键指标汇总】 训练了 97 个 epoch,最终轮指标: 指标 | 数值 mAP50 | **0.8213** mAP50-95 | 0.6707 Precision | 0.8858 Recall | 0.7370 train/box_loss | 0.5927 train/cls_loss | 0.4692 val/box_loss | 0.7097 val/cls_loss | 0.8245 【训练过程分析】 训练过程中,模型在前几轮迅速收敛,loss 值从 0.5927 降到 0.7097,表明初期训练效果显著。loss 在第 10 轮降至最低点 0.5867,然后在接下来的 80 轮左右保持平稳,仅微幅波动在 0.5927 到 0.6000 之间,显示训练过程较为均衡,没有明显的过拟合迹象。整体来看,模型在训练后期趋于稳定,mAP50 从 0.6845 增长至 0.8213,提升较为平滑,显示出训练效果的稳健性。 模型在第 97 轮时,loss 稳定在较低水平,表明训练过程较为稳定,没有明显的过拟合迹象。从 PR 曲线可见,模型在检测精度和召回率方面表现均衡,特别是在高召回率时保持较高的精度。mAP50 为 0.8213,表明模型在中等难度的检测任务上表现良好。然而,mAP50-95 为 0.6707,说明在高难度检测任务... 使用场景:毕业设计、课程设计、深度学习入门、工业场景落地验证。


