字串搜尋取代問題 |
答題得分者是:syntax
|
ycl2005
一般會員 發表:15 回覆:14 積分:5 註冊:2005-10-01 發送簡訊給我 |
我想寫一個程式,是用來修改遊戲中的存檔內容,
程式內容如下, 請高手指點,謝謝. var iFileHandle1: Integer; iFileLength: Integer; iBytesRead: Integer; Buffer: PChar; i: Integer; str1:string; begin try //把遊戲存檔讀入buffer中 iFileHandle1 := FileOpen(ExtractFilePath(application.ExeName) '\' TargetFile, fmOpenRead); iFileLength := FileSeek(iFileHandle1,0,2); FileSeek(iFileHandle1,0,0); Buffer := PChar(AllocMem(iFileLength 1)); iBytesRead := FileRead(iFileHandle1, Buffer^, iFileLength); FileClose(iFileHandle1); //現在問題出在這一段 for i := 0 to iBytesRead-1 do begin //我要搜尋 16進位 216F 的資料, 然後改成 16進位 255B不曉得要從何下手 Str1 :=Buffer[i]; end; //把buffer中的內容存檔 iFileHandle1 := FileCreate(ExtractFilePath(application.ExeName) '\' TargetFile); FileWrite(iFileHandle1,Buffer^,iFileLength); FileClose(iFileHandle1); finally FreeMem(Buffer); end; end; |
pcboy
版主 發表:177 回覆:1838 積分:1463 註冊:2004-01-13 發送簡訊給我 |
Chr(charcode) Remarks The charcode argument is a number that identifies a character. Numbers from 0 to 31 are the same as standard, nonprintable ASCII codes. For example, Chr(10) returns a linefeed character. The following example uses the Chr function to return the character associated with the specified character code: Copy Code Dim MyChar MyChar = Chr(65) ' Returns A. MyChar = Chr(97) ' Returns a. MyChar = Chr(62) ' Returns >. MyChar = Chr(37) ' Returns %. ============================= Hex(number) Remarks The number argument is any valid expression. If number is not already a whole number, it is rounded to the nearest whole number before being evaluated. If number is Hex returns Null Null. Empty Zero (0). Any other number Up to eight hexadecimal characters. You can represent hexadecimal numbers directly by preceding numbers in the proper range with &H. For example, &H10 represents decimal 16 in hexadecimal notation. The following example uses the Hex function to return the hexadecimal value of a number: Copy Code Dim MyHex MyHex = Hex(5) ' Returns 5. MyHex = Hex(10) ' Returns A. MyHex = Hex(459) ' Returns 1CB.
------
能力不足,求助於人;有能力時,幫幫別人;如果您滿意答覆,請適時結案! 子曰:問有三種,不懂則問,雖懂有疑則問,雖懂而想知更多則問! |
syntax
尊榮會員 發表:26 回覆:1139 積分:1258 註冊:2002-04-23 發送簡訊給我 |
|
ycl2005
一般會員 發表:15 回覆:14 積分:5 註冊:2005-10-01 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |