关于Delphi XE8的ansistring的问题

heihei122 2017-04-10 09:27:35
最近在用Delphi XE8写一个小项目,在项目进行中遇到一个问题,我用D7写的类,在D7中运行时好的,但是到了XE8后,出现异常,而且这个异常很是奇怪对某个类的其中一个私有属性(ansistring类型)赋值,赋值可以取到到但是到了获取的时候就报错,第一次调用此函数的时候 不会报错,第二次的时候就报错;
函数里面就是一个简单的把字符串串联起来,后来我对一个长的字符串(大于512字节)用循环的方式取去,又可以了,不知道是不是我的函数问题还是ansistring的值太长了导致内存泄漏;
函数的大致意思的
function getAsBinStr:ansistring;
var
temp:ansistring;
i:integer;
begin
temp := strA + strB + FData;
(报错);
修改为 就可以了
temp := strA + strB ;
for i:=1 to length(temp) do
begin
temp := temp + FData[i];
end;
end;
...全文
432 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
FData是string吗?
type TShowStr = record X: Word; Y: Word; S: array [0 .. 43] of AnsiChar; end; type TCamera = record pHWND: HWND; strict private aCam: LongInt; g_nPort: LongInt; struDeviceInfo: NET_DVR_DEVICEINFO_V30; lRealHandle: LongInt; struPlayInfo: NET_DVR_CLIENTINFO; pUser: Pointer; dwRet: Integer; public property ErrCode: Integer read dwRet; procedure HCLogin(IP, User, Psd: String; Port: Word); procedure HCPlay(aHWND: HWND); procedure HCAddChar(str: TArray); procedure HCAddChar_V30(str: TArray); function HCGetJpeg(JpgName: String; JpgSize: Word = 0; JpgQua: Word = 19): Boolean; procedure HCStop; procedure HCLogout; end; {$ENDIF //} implementation procedure TCamera.HCLogin(IP, User, Psd: String; Port: Word); begin NET_DVR_Init(); lRealHandle := -1; dwRet := 0; aCam := NET_DVR_Login_V30(PAnsiChar(ansistring(IP)), Port, PAnsiChar(ansistring(User)), PAnsiChar(ansistring(Psd)), @struDeviceInfo); dwRet := NET_DVR_GetLastError; end; procedure TCamera.HCPlay(aHWND: HWND); begin struPlayInfo.lChannel := 1; struPlayInfo.lLinkMode := 0; struPlayInfo.sMultiCastIP := NIL; struPlayInfo.hPlayWnd := aHWND; lRealHandle := NET_DVR_RealPlay_V30(aCam, @struPlayInfo, nil, pUser, true); dwRet := NET_DVR_GetLastError; end; procedure TCamera.HCAddChar(str: TArray); var i: Integer; aStr: NET_DVR_SHOWSTRING; begin if length(str) > MAX_STRINGNUM then begin setlength(str, MAX_STRINGNUM); end; for i := 0 to length(str) - 1 do begin aStr.struStringInfo[i].wShowString := 1; aStr.struStringInfo[i].wStringSize := length(str[i].S); aStr.struStringInfo[i].wShowStringTopLeftX := str[i].X; aStr.struStringInfo[i].wShowStringTopLeftY := str[i].Y; move(str[i].S[0], aStr.struStringInfo[i].sString[0], length(str[i].S)); end; aStr.dwSize := sizeof(aStr); NET_DVR_SetDVRConfig(aCam, NET_DVR_SET_SHOWSTRING, 1, @aStr, sizeof(NET_DVR_SHOWSTRING)); dwRet := NET_DVR_GetLastError; end; procedure TCamera.HCAddChar_V30(str: TArray); var i: Integer; aStr: NET_DVR_SHOWSTRING_V30; begin if length(str) > MAX_STRINGNUM_V30 then begin setlength(str, MAX_STRINGNUM_V30); end; for i := 0 to length(str) - 1 do begin aStr.struStringInfo[i].wShowString := 1; aStr.struStringInfo[i].wStringSize := length(str[i].S); aStr.struStringInfo[i].wShowStringTopLeftX := str[i].X; aStr.struStringInfo[i].wShowStringTopLeftY := str[i].Y; move(str[i].S[0], aStr.struStringInfo[i].sString[0], length(str[i].S)); end; aStr.dwSize := sizeof(aStr); NET_DVR_SetDVRConfig(aCam, NET_DVR_SET_SHOWSTRING_V30, 1, @aStr, sizeof(NET_DVR_SET_SHOWSTRING_V30)); dwRet := NET_DVR_GetLastError; end; function TCamera.HCGetJpeg(JpgName: String; JpgSize: Word = 0; JpgQua: Word = 19): Boolean; var aJpg: NET_DVR_JPEGPARA; begin aJpg.wPicSize := JpgSize; aJpg.wPicQuality := JpgQua; if aCam >= 0 then begin result := NET_DVR_CaptureJPEGPicture(aCam, 1, aJpg, PAnsiChar(ansistring(JpgName))); dwRet := NET_DVR_GetLastError(); end else result := false; dwRet := NET_DVR_GetLastError; end; procedure TCamera.HCStop; begin if lRealHandle >= 0 then begin NET_DVR_StopRealPlay(lRealHandle); lRealHandle := -1; end; PlayM4_CloseStream(g_nPort); PlayM4_FreePort(g_nPort); end; procedure TCamera.HCLogout; begin if lRealHandle > -1 then begin HCStop; end; if aCam >= 0 then begin NET_DVR_Logout_V30(aCam); aCam := -1; end; NET_DVR_Cleanup(); end;
1stClass Studio XE6 –4/29/14 –Version 14.0.1.1 System Requirements RAD Studio XE6 Compatibility issues of 1stClass Studio/Win32: 1stClass Studio XE6 is designed to be backwards compatible with 1stClass XE5, XE4,2013, 2012, 2011, 2010, 2009, 2007, 2006, and 1stClass 4000. The only change for versions of 1stClass prior to 2006 is for the TfcImageForm. If you are using this component in a dialog, you will need to call the ApplyBitmapRegion method for the imageform from your form’s OnShow event. fcImageForm1.ApplyBitmapRegion; Without the above code, the form will not take on the shape of the image form’s bitmap. C++ backwards compatibility : For C++ projects there are a few housecleaning items to take care of in your project to compile with the new version. They are listed as follows. 1. If you use the OnDrawText event of a StatusBar panel, then you will need to change the reference of AnsiString & Text to UnicodeString & Text. Change this for both the header (.h) file and the source file (.cpp). 2. Existing C++ Builder projects will need to modify the references to the infopower header files so that they are preceeded by vcl. For instance, if you have a reference to … #include “fcstatusbar.hpp” in your source header file, this will need to be changed to #include “vcl.fcstatusbar.hpp” 3. Similarly C++ Project source files will need to change the references to the #pragma reference to also be preceeded by a vcl. For instance if you have a reference to … #pragma link "fcstatusbar" in your source .cpp file, this will need to be changed to #pragma link "vcl.fcstatusbar" Installing the 1stClass help file The online help files are integrated automatically Demo Applications For an overview of the 1stClass functionality, we suggest you compile the main demonstration program for 1stClass. This demo is located at \fcStudioxe6\demos\windows\Demo1stClass.dproj Company Information Address: Woll2Woll Software 3150 Reed Ave. Livermore, CA 94550 Sales: U.S. - 800-WOL2WOL (1-800-965-2965) INTL - 1-925-371-1663 Voice: (925) 371-1663 Fax: (925) 215-2410 Internet: mailto:sales@woll2woll.net Web site: http://www.woll2woll.com/

16,749

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 语言基础/算法/系统设计
社区管理员
  • 语言基础/算法/系统设计社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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