delphi中的pchar类型在bcb中是什么

jumphigh 2001-01-13 11:59:00
void __fastcall TForm1::flb1Click(TObject *Sender)
{
ShellExecute(0,NULL,(LPCSTR)flb1->FileName,NULL,NULL,SW_NORMAL);
}

我现在的想法是这样的
click listbox中的一个文件
调用于他关联的执行文件
执行

现在的关键是shellexecute的第三个参数是个LPCSTR --指向常量字符串的指针
而file full name是个变量字符串

改操作在delphi是这样的
procedure TForm1.FileListBox1DblClick(Sender: TObject);
var
s:string;
begin
s:=filelistbox1.FileName;
ShellExecute(0,nil,pchar(s),nil,nil,SW_NORMAL);
end;
换到bc中怎么办
...全文
193 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
comanche 2001-01-14
  • 打赏
  • 举报
回复
PChar是char*

这句话这样写

ShellExecute( 0, 0, s.c_str( ), 0, 0, SW_NORMAL )
babysloth 2001-01-14
  • 打赏
  • 举报
回复
不太可能,除非你用了什么WIN2000的特性,一般不会的.
jumphigh 2001-01-14
  • 打赏
  • 举报
回复

谢谢
已经解决了
分数马上给

还有个问题
bcb5编译的文件在2000下可以运行,到了98下就不行了
这是什么原因

library fundll; { 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, // ShareMem 一定放第一个 Windows, Messages, SysUtils, math, strutils, registry , StdCtrls, ExtCtrls, ADODB, DB,dateutils,Dialogs; // fucs in 'fucs.pas'; const INPASSSTR='89ABCDEFGcdefghijkHIJ%^KLMN0123opqrstuOP -_\|/?@#$&*' ; //切记:Library 的名字大小写没关系,可是DLL-Func的大小写就有关系了。 // 在 DLL-Func-Name写成MyMax与myMAX是不同的。如果写错了,立即的结果是你调用到此DLL的AP根本开不起来。 //参数的大小写就没关系了。甚至不必同名。如原型是 (X,Y:integer)但引用时写成(A,B:integer),那是没关系的。 //切记:要再加个stdcall。书上讲,如果你是用Delphi写DLL,且希望不仅给 Delphi-AP也希望BCB/VC-AP等使用的话,那你最好加个Stdcall ; //参数型态:Delphi有很多种它自己的变量型态,这些当然不是DLL所喜欢的,Windows/DLL的母语应该是C。所以如果要传进传出DLL的参数,我们尽可能照规矩来用。这两者写起来,后者会麻烦不少。如果你对C不熟的话,那也没关系。我们以后再讲。 //3.将这些可共享的Func送出DLL,让外界﹝就是你的Delphi-AP啦﹞使用: //光如此,你的AP还不能用到这些,你还要加个Exports才行。 代码: //=============比较大小的函数=============== Function MyMax ( X , Y : integer ) : integer ; stdcall ; //stdcall 可以让 BCB/VC-AP等使用的 begin if X > Y then Result := X else Result := Y ; end ; //==============加密======================= function Inpass(s:string):string; stdcall ; var i:integer; passstr,dd:string; begin for i:=1 to length(s) do begin dd:=inttohex(ansipos(s[i],inpassstr),4); if dd='0000' then begin result:='0';exit end; passstr:=passstr+dd ; end; Result :=passstr; end; //==============解密======================= function Outpass(s:string):string;stdcall ; var pass,dd:string; i,leng:integer; begin leng:= floor(length(s)/4); pass:=''; for i:=1 to leng do begin dd:=ansimidstr(s,(i-1)*4+1,4); if strtoint('$'+dd)=0 then begin result:='0';exit;end; if strtoint('$'+dd)>78 then begin result:='0'; exit end; pass:=pass+ansimidstr(inpassstr,strtoint('$'+dd),1) ; end; Result :=pass ; end; //==========test========================= function jsjyh(strym:string):string;stdcall; var newstr1,he,oldstr:string; tj:boolean; i:integer; begin i:=1; he:=''; tj:=true; // 取出要参与校验和计算的字符串给oldstr if (length(strym) mod 2)0 then begin showmessage('你输入的源码个数有错,不能是奇数个,请重输入!'); exit; end; oldstr:=trim(strym); while tj=true do begin newstr1:=copy(oldstr,i,2); oldstr:=copy(oldstr,i+2,length(oldstr)-2); //开始计算校验和并给he变量 if he='' then begin he:=inttohex(strtointdef('$'+newstr1,16)+ strtointdef('$'+'00',16),2); he:=rightstr(he,2); end else begin he:=inttohex(strtointdef('$'+newstr1,16)+ strtointdef('$'+he,16),2); he:=rightstr(he,2); end; if length(oldstr) =0 then tj:=false; end; result:=strym+he; end; //============================================== {$R *.RES} //将这些可共享的Func送出DLL,让外界﹝就是你的Delphi-AP啦﹞使用: //光如此,你的AP还不能用到这些,你还要加个Exports才行。 代码: exports MyMax,Inpass,Outpass,jsjyh; begin end.

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧