📄 ucommon.~pas
字号:
lsResultStr := lsResultStr +
Char(StrToInt(lsStr1) * StrToInt(lsStr2) + StrToInt(lsStr4));
end;
except
Result := '';
end;
end;
Result := lsResultStr;
end;
//******************************************************************************
// 函数功能: 设置信息到INI文件中
// 函数名称: gcf_SetINIValue(sSection,sIdent,sValue:String):boolean;
// 函数参数: sSection String 小节
// sIdent String 字段
// sValue String 字段值
// 返回值: 返回是否操作成功
//******************************************************************************
function gcf_SetINIValue(sSection, sIdent, sValue: string): boolean;
var
strPath: string;
objIniF: TIniFile;
begin
//写配置文件
Result := False;
strPath := ExtractFilePath(ParamStr(0)) + DEF_INIFILENAME;
objIniF := TIniFile.Create(strPath);
if (sSection = '') or (sIdent = '') or (sValue = '') then
begin
Exit;
end;
try
objIniF.WriteString(sSection, sIdent, sValue);
Result := True;
finally
objIniF.Free;
end;
end;
//******************************************************************************
// 函数功能: 读取INI文件中得信息.
// 函数名称: gcf_GetINIValue(sSection,sIdent:String):String;
// 函数参数: sSection String 小节
// sIdent String 字段
// sValue String 字段值
// 返回值: 返回读取对应节,字段的字段值.
//******************************************************************************
function gcf_GetINIValue(sSection, sIdent: string): string;
var
strPath: string;
objIniF: TIniFile;
begin
//写配置文件
Result := '';
strPath := ExtractFilePath(ParamStr(0)) + DEF_INIFILENAME;
objIniF := TIniFile.Create(strPath);
if (sSection = '') or (sIdent = '') then
begin
Exit;
end;
try
Result := objIniF.ReadString(sSection, sIdent, '');
finally
objIniF.Free;
end;
end;
//******************************************************************************
// 函数功能: 设置信息到注册表
// 函数名称: gcf_SetRegValue(sSection,sIdent,sValue:String):boolean;
// 函数参数: sSection String 小节
// sIdent String 字段
// sValue String 字段值
// 返回值: 返回是否操作成功
//******************************************************************************
function gcf_SetRegValue(sSection, sIdent, sValue: string): boolean;
var
Reg: TRegistry;
begin
Result := False;
Reg := TRegistry.Create;
try
Reg.RootKey := DEF_REGROOT;
if Reg.OpenKey(sSection, True) then
begin
try
Reg.WriteString(sIdent, sValue);
Result := True;
except
Result := False;
end;
end
else Result := False;
finally
Reg.CloseKey;
Reg.Free;
end;
end;
//******************************************************************************
// 函数功能: 读取指定的注册表信息值
// 函数名称: gcf_GetRegValue(sSection,sIdent,sValue:String):String;
// 函数参数: sSection String 小节
// sIdent String 字段
// 返回值: 是否操作成功
//******************************************************************************
function gcf_GetRegValue(sSection, sIdent: string): string;
var
Reg: TRegistry;
begin
Result := '';
Reg := TRegistry.Create;
try
Reg.RootKey := DEF_REGROOT;
if Reg.OpenKey(sSection, False) then
begin
try
Result := Reg.ReadString(sIdent);
except
Result := '';
end;
end
else Result := '';
finally
Reg.CloseKey;
Reg.Free;
end;
end;
//******************************************************************************
// 函数功能: 删除指定的注册表信息
// 函数名称: gcf_DeleteRegValue(sSection,sIdent:String):String;
// 函数参数: sSection String 小节
// sIdent String 字段
// 返回值: 是否操作成功
//******************************************************************************
function gcf_DeleteRegValue(sSection, sIdent: string): Boolean;
var
Reg: TRegistry;
begin
Result := False;
Reg := TRegistry.Create;
try
Reg.RootKey := DEF_REGROOT;
if Reg.OpenKey(sSection, True) then
begin
try
Reg.DeleteValue(sIdent);
Result := True;
except
Result := False;
end;
end
else Result := False;
finally
Reg.CloseKey;
Reg.Free;
end;
end;
//******************************************************************************
// 函数功能: 获取程序路径
// 函数名称: gcf_GetAppPath
// 函数参数: 无参数
// 返回值: 当前应用程序路径
//******************************************************************************
function gcf_GetAppPath: string;
begin
Result := ExtractFilePath(Paramstr(0));
end;
//******************************************************************************
// 函数功能: 设置连接数据库服务器配置信息
// 函数名称: gcf_SetDBConInfo
// 函数参数: aCon :TCon 服务器连接记录结构体变量
// iIndex:Integer 服务器连接信息索引
// 返回值: 是否操作成功
//******************************************************************************
function gcf_SetDBConInfo(aCon: TCon; iIndex: Integer = 1): boolean;
var
sIndex: string;
sSection: string;
begin
Result := False;
try
sIndex := IntToStr(iIndex);
sSection := 'DATABASE';
gcf_SetINIValue(sSection, 'SERVERNAME' + sIndex, aCon.sServerName);
gcf_SetINIValue(sSection, 'DATABASENAME' + sIndex, aCon.sDatabaseName);
gcf_SetINIValue(sSection, 'USERNAME' + sIndex, aCon.sUserName);
gcf_SetINIValue(sSection, 'PASSWORD' + sIndex, aCon.sPassWord);
gcf_SetINIValue(sSection, 'DBTYPE' + sIndex, aCon.sDBType);
if UpperCase(aCon.sDBType) = 'ACCESS' then
begin
if Trim(aCon.sFilePath) <> '' then
gcf_SetINIValue(sSection, 'DBPATH' + sIndex, aCon.sFilePath)
else
gcf_SetINIValue(sSection, 'DBPATH' + sIndex, DEF_VISUAL_DBPATH);
end;
Result := True;
except
Result := False;
end;
end;
//******************************************************************************
// 函数功能: 设置LED屏配置信息
// 函数名称: gcf_SetLEDCfgInfo
// 函数参数: aLedScreen :TLedScreen LED屏配置相关信息
// iIndex:Integer 信息索引
// 返回值: 是否操作成功
//******************************************************************************
function gcf_SetLEDCfgInfo(aLedScreen: TLedScreen; iIndex: Integer = 1): Boolean;
var
sIndex: string;
sSection: string;
begin
Result := False;
try
sIndex := IntToStr(iIndex);
sSection := 'LEDSCREEN';
gcf_SetINIValue(sSection, 'LEDID' + sIndex, IntToStr(aLedScreen.iLedID));
gcf_SetINIValue(sSection, 'LEDTYPE' + sIndex, IntToStr(aLedScreen.iLedType));
gcf_SetINIValue(sSection, 'LEDCOLOR' + sIndex, IntToStr(aLedScreen.iLedColor));
gcf_SetINIValue(sSection, 'LEDPORT' + sIndex, IntToStr(aLedScreen.iLedPort));
gcf_SetINIValue(sSection, 'LEDBAUDRATE' + sIndex, IntToStr(aLedScreen.iLedBaudRate));
gcf_SetINIValue(sSection, 'LEDWIDTH' + sIndex, IntToStr(aLedScreen.iLedWidth));
gcf_SetINIValue(sSection, 'LEDHEIGHT' + sIndex, IntToStr(aLedScreen.iLedHeight));
gcf_SetINIValue(sSection, 'LEDFREQUENCY' + sIndex, IntToStr(aLedScreen.iLedFrequency));
gcf_SetINIValue(sSection, 'LEDDATAOFF' + sIndex, IntToStr(aLedScreen.iLedDataOff));
gcf_SetINIValue(sSection, 'LEDRAM' + sIndex, IntToStr(aLedScreen.iLedRam));
gcf_SetINIValue(sSection, 'LEDCYCLE' + sIndex, IntToStr(aLedScreen.iLedCyCle));
gcf_SetINIValue(sSection, 'LEDSPEED' + sIndex, IntToStr(aLedScreen.iLedSpeed));
gcf_SetINIValue(sSection, 'LEDTIME' + sIndex, IntToStr(aLedScreen.iLedTime));
gcf_SetINIValue(sSection, 'LEDSTUNT' + sIndex, IntToStr(aLedScreen.iLedStunt));
gcf_SetINIValue(sSection, 'LED_MKTYPE' + sIndex, IntToStr(aLedScreen.iLed_MKType));
gcf_SetINIValue(sSection, 'LED_DATADA' + sIndex, IntToStr(aLedScreen.iLed_DataDA));
gcf_SetINIValue(sSection, 'LED_DATAOE' + sIndex, IntToStr(aLedScreen.iLed_DataOE));
gcf_SetINIValue(sSection, 'LED_FILENAME' + sIndex, aLedScreen.sLed_FileName);
gcf_SetINIValue(sSection, 'LED_SENDDATATYPE' + sIndex, IntToStr(aLedScreen.iLed_SendDataType));
gcf_SetINIValue(sSection, 'LED_COMPORT' + sIndex, aLedScreen.sLed_ComPort);
gcf_SetINIValue(sSection, 'LED_TW_X' + sIndex, IntToStr(aLedScreen.iLed_TW_x));
gcf_SetINIValue(sSection, 'LED_TW_Y' + sIndex, IntToStr(aLedScreen.iLed_TW_y));
gcf_SetINIValue(sSection, 'LED_TW_WIDTH' + sIndex, IntToStr(aLedScreen.iLed_TW_Width));
gcf_SetINIValue(sSection, 'LED_TW_HEIGHT' + sIndex, IntToStr(aLedScreen.iLed_TW_Height));
gcf_SetINIValue(sSection, 'LED_FILETYPE' + sIndex, IntToStr(aLedScreen.iLed_FileType));
gcf_SetINIValue(sSection, 'LED_DELETED' + sIndex, BoolToStr(aLedScreen.bLed_Deleted));
gcf_SetINIValue(sSection, 'LEDFONTNAME' + sIndex, aLedScreen.sLed_FontName);
gcf_SetINIValue(sSection, 'LEDFONTSIZE' + sIndex, IntToStr(aLedScreen.iLed_FontSize));
gcf_SetINIValue(sSection, 'LEDACTIVEFONTNAME' + sIndex, aLedScreen.sLed_ActiveFontName);
gcf_SetINIValue(sSection, 'LEDACTIVEFONTSIZE' + sIndex, IntToStr(aLedScreen.iLed_ActiveFontSize));
aLedScreen.iLedCount := 0;
Result := True;
except
Result := False;
end;
end;
//******************************************************************************
// 函数功能: 读取LED屏配置信息
// 函数名称: gcf_GetLEDCfgInfo
// 函数参数: aLedScreen :TLedScreen LED屏配置相关信息
// iIndex:Integer 索引值
// 返回值: 是否操作成功
//******************************************************************************
function gcf_GetLEDCfgInfo(var aLedScreen: TLedScreen; iIndex: Integer = 1): Boolean;
var
sSection,
sIndex: string;
begin
Result := False;
try
sSection := 'LEDSCREEN';
sIndex := IntToStr(iIndex);
aLedScreen.iLedID := StrToIntDef(gcf_GetINIValue(sSection, 'LEDID' + sIndex), 1);
aLedScreen.iLedType := StrToIntDef(gcf_GetINIValue(sSection, 'LEDTYPE' + sIndex), DEF_LEDTYPE);
aLedScreen.iLedColor := StrToIntDef(gcf_GetINIValue(sSection, 'LEDCOLOR' + sIndex), 1);
aLedScreen.iLedPort := StrToIntDef(gcf_GetINIValue(sSection, 'LEDPORT' + sIndex), 1);
aLedScreen.iLedBaudRate := StrToIntDef(gcf_GetINIValue(sSection, 'LEDBAUDRATE' + sIndex), DEF_LEDBAUDRATE);
aLedScreen.iLedWidth := StrToIntDef(gcf_GetINIValue(sSection, 'LEDWIDTH' + sIndex), DEF_LEDWIDTH);
aLedScreen.iLedHeight := StrToIntDef(gcf_GetINIValue(sSection, 'LEDHEIGHT' + sIndex), DEF_LEDHEIGHT);
aLedScreen.iLedFrequency := StrToIntDef(gcf_GetINIValue(sSection, 'LEDFREQUENCY' + sIndex), 4);
a
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -