

运行时提示: List index out of bounds(19)
原因在使用Tstringlist时, 循环for i := 0 to list.count-1, 这里要减1,因为是从0开始的,循环时总行数不减1就会出这个问题
编译时提示:[Error] Unit1.pas(75): Constant object cannot be passed as var parameter
原因:〔错误〕第一单元.pas(75):常量对象不能作为var参数传递,就是你声明函数的参数是变量,就必须传变量进去,声明常量就传常量
function runstr(var findstr,typestr:string):string; //这里的的函数参数是变量,不能这样调用,runstr('php','txt');
function runstr(const findstr,typestr:string):string; //改成这样就可以runstr('php','txt');
主要原因是函数用var声明参数时,传值用的是传地址的方式
编译时提示:[Warning] Unit1.pas(58): Constructing instance of 'TStrings' containing abstract method 'TStrings.Clear'
意思是说Tstrings类是抽象类,它的一些抽象方法如clear只是方法名,没有写实现的代码,抽象类的抽象方法是在继承它的子类的写的,
如继承自Tstrings的Tstringlist的那些方法是有实现代码的,所有实例化类的,只能实例化子类TstringList,而不能实例化抽象的父类Tstrings
编译时提示Unsatisfied forward or external declaration:错误
原因:函数实现部分是从单元文件复制过的,没有加函数前加form1,在form1窗口的新建的函数,在申明部分可以不加form1,但在实的部分要加form1,
function TForm1.aaa: string; //在实现部分这里要是写成function aaa: string; 就会提示这个错误
在获取桌面路径时遇到[Error] Unit2.pas(21): Undeclared identifier: 'handle'错误
解决方法:shGetSpecialFolderLocation(handle,CSIDL_DESKTOP,pitem);将里面的handle改为0就可以了
[Error] Unit1.pas(34): String literals may have at most 255 elements
delphi开发软件中中string字符串赋值一行不能超过255个字符,可以用+分成多行写就可以了
1.Project Project1.exe raised exception class EIdCouldNotBind Socket with message 'Could not bind socket. Address and port are already in use.'. Process stoped. Use Step or run to continue.
不能连接Cocket,地址和端口已被使用,进程中止,使步进运行或继续。解决:1(有的可用)
工程生成的Exe运行也提示:Could not bind cocket,这个重启电脑就解决了
解决方法2:
IdTCPServer1.Active := True改为:
IdTCPServer1.Active := false
2.Project H_Client.exe raised exception class EConvertError with message ''$' is not a valid integer value'.
工程HClient.exe中出现了一个转换异常的错误,即“$”不是一个有效的整数值.
解决:将灰鸽子中LjPassword.Text:=DeCryptStr(Myinifile.Readstring('Operation', 'PassWord', ''),'HEIMAYI');改为:LjPassword.Text:=Myinifile.Readstring('Operation', 'PassWord', '');
应该是这个DeCryptStr加密函数不能转换“$”
3.Exected '=' but '('found in class Tcient.
4.Expression expected but '>'found 表要求的类型'>'不能发现
========================================================
//==============================================================================
// 关于Delphi编译产生警告的几点总结
// 这些警告或提示并不影响程序的正常编译。。。
//==============================================================================
1) 关于运行平台的警告信息
[Warning] frm_main.pas(3): Unit 'ShellCtrls' is specific to a platform
解决办法:在 uses 语句后加一行:{$WARN UNIT_PLATFORM OFF}
//----------------------------------------------------------------------------
//提示你的程序引用的单元或使用的控件,只能在Windows平台下运行正常
//而在Linex或者其他的操作系统下会出问题
//如果你的系统只运行在Windows下. 那么这种警告不用管它
//----------------------------------------------------------------------------
2) 关于分配值从未使用的提示
对于指针变量若提示:
[Hint] MMClass.pas(208): Value assigned to 'P' never used
procedure TMMClass.SpString(S: String);
var
P: PChar;
Stmp:string;
begin
Stmp:=S;
P:= @Stmp[1];
... ...
FreeAndNil(P);
~~~~~~~~~~~~~~
end;
//--------------------------------------------------------------------------
//指针使用完后这样释放 FreeAndNil(P),否则,可能提示上面提示
//--------------------------------------------------------------------------
3) 关于使用抽象类的警告
例如:
StrList:Tstrings;
StrList:=Tstrings.Create;
[Warning] Unit1.pas(45): Constructing instance of 'TStrings' containing abstract method 'TStrings.Clear'
[Warning] Unit1.pas(45): Constructing instance of 'TStrings' containing abstract method 'TStrings.Delete'
[Warning] Unit1.pas(45): Constructing instance of 'TStrings' containing abstract method 'TStrings.Insert'
//----------------------------------------------------------------------------
//抽象类错误,tstrings 是很多次类,如tstringlist的基类,
//有很多方法只有声明没有定义,在子类中才实现,
//因此,你调用了一些抽象方法如insert后,将产生错误提示
//将Tstrings.Create中的Tstrings改为TstringList。
//----------------------------------------------------------------------------
4)关于 Delphi7 不安全的类型警告
[Warning] Unit1.pas(47): Unsafe type 'procedure, untyped pointer or untyped parameter'
[Warning] Unit1.pas(51): Unsafe type 'procedure, untyped pointer or untyped parameter'
[Warning] Unit1.pas(65): Unsafe typecast of 'procedure, untyped pointer or untyped parameter' to 'TForm'
[Warning] Unit1.pas(87): Unsafe typecast of 'procedure, untyped pointer or untyped parameter' to 'TForm'
//----------------------------------------------------------------------------
//这些警告是针对.net的
//把Project/Options/Compiler Messages/Warnings 中 [UnsafeType、UnsafeCode、UnsafeCast] 的对勾去掉。
Too many actual parameters
====================================================================
uses SvcMgr,WinSvc单元,然后自己继承一个TService类,用于响应Start和Stop
在project代码中用
SvcMgr.Application.Initialize;
YourService := TYourService.CreateNew(SvcMgr.Application, 0);
Application.Title := 'VSPM虚拟串口';
SvcMgr.Application.CreateForm(TYourform, YourForm);
初始化