Home
Top.Mail.Ru Yandeks.Metrika
Forum: "Main";
Current archive: 2002.01.08;
Download: [xml.tar.bz2];

Down

Could not save resource to file Find similar branches


Reyst   (2001-12-16 15:56) [0]

Dear masters! I am writing in C ++, but I needed to write a program in Delphi.
In the code below, when executed, two lines are “ignored”,
marked !!!, despite the fact that the code for them is generated
(in the code browser, the lines are marked with a blue dot, optimization is disabled).
Question: why? I suspect the dog is buried in StrCat,
because not completely figured out the lines in Pascal,
despite the obvious affinity of PChar with "string" strings.
(FullPath - global variable, PChar)

function DoResource (Instance: HModule; ResType: PChar;
ResName: PChar; Param: Longint): BOOL; stdcall;
was
Res: TResourceStream;
FileName: PChar;
begin
GetMem (FileName, 255);
FileName ^: = Chr (0);
Res: = TResourceStream.Create (Instance, ResName, ResType);
!!! FileName: = StrCat (FullPath, ResName);
!!! Res.SaveToFile (FileName);
Res.Free;
DoResource: = true;
end;



PVR   (2001-12-16 19:35) [1]

function DoResource (Instance: HModule; ResType: PChar;
ResName: PChar; Param: Longint): BOOL; safacall {!!!!!!};
was
Res: TResourceStream;
FileName: PChar;
begin
GetMem (FileName, 255);
try
FileName ^: = Chr (0);
with TResourceStream.Create (Instance, ResName, ResType) do
try
!!! FileName: = StrCat (FullPath, ResName);
!!! SaveToFile (FileName);
finally
Res.Free;
end;
DoResource: = true;
finally
freemem (filename);
end
end;



MrBeer   (2001-12-16 19:54) [2]

// ......
FileName: = StrAlloc (512);
Res: = TResourceStream.Create (Instance, ResName, ResType)
StrCopy (FileName, FullPath);
StrCat (FileName, ResName);
Res.SaveToFile (StrPas (FileName));
Res.Free;
StrDispose (FileName);
// ......



MrBeer   (2001-12-16 19:59) [3]

+ zhelatelno

vmesto StrCat polzovatj StrLCat & try block sdelatj.

best regards.



Reyst   (2001-12-16 20:03) [4]

> MrBeer.
And so it was. I just removed everything to the maximum during the glitch search.
Thank you!



PVR   (2001-12-16 22:22) [5]

function DoResource (Instance: HModule; ResType: PChar;
ResName: PChar; Param: Longint): BOOL; safecall {!!!!!!};
was
FileName: string;
begin
GetMem (FileName, 255);
try
FileName: = "";
with TResourceStream.Create (Instance, ResName, ResType) do
try
!!! FileName: = FullPath + string (ResName);
!!! SaveToFile (FileName);
finally
Res.Free;
end;
DoResource: = true;
finally
freemem (filename);
end
end;



Pages: 1 whole branch

Forum: "Main";
Current archive: 2002.01.08;
Download: [xml.tar.bz2];

Top





Memory: 0.56 MB
Time: 0.032 c
1-22105
Gonza
2001-12-19 16:35
2002.01.08
MDI Application ???


1-22120
Leviathan
2001-12-19 22:26
2002.01.08
Libraries of icons


1-22113
Yuraz
2001-12-19 20:25
2002.01.08
Brothers why


6-22278
garage
2001-10-02 12:27
2002.01.08
Tell me the algorithm for replacing large letters with small letters.


1-22232
T2
2001-12-16 07:24
2002.01.08
WIN386.SWP





afrikaans albanian Arabic armenian azerbaijani basque belarusian bulgarian catalan Chinese (Simplified) Chinese (Traditional) croatian Czech danish Dutch English estonian filipino finnish French
galician georgian German greek haitian Creole hebrew Hindi hungarian icelandic indonesian Irish italian Japanese Korean latvian lithuanian macedonian malay maltese norwegian
persian polish portuguese Romanian russian serbian slovak Slovenian Spanish swahili Swedish thai turkish Ukrainian urdu vietnamese welsh yiddish bengali bosnian
cebuano Esperanto gujarati hausa hmong igbo javanese kannada Khmer lao latin maori marathi mongolian nepali punjabi somali tamil telugu yoruba
zulu
English French German Italian Portuguese Russian Spanish