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]

Уважаемые мастера! Пишу на C++, но понадобилось написать программу на Delphi.
В нижеприведенном коде при выполнении "игнорируются" две строки,
помеченные !!!, несмотря на то, что код для них генерируется
(в браузере кода строки отмечены синей точкой, оптимизация отключена).
Вопрос: почему? Подозреваю, что собака зарыта в StrCat,
т.к. не до конца разобрался со строками в Паскале,
несмотря на явное родство PChar с "сишными" строками.
(FullPath - глобальная переменная, 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.
А так и было. Просто я на время поиска глюка все убрал по максимуму.
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.82 MB
Time: 0.033 c
1-22051
kay
2001-12-18 22:22
2002.01.08
Richedit


14-22346
Ivan Shikhalev
2001-11-06 20:30
2002.01.08
Haiku :))


3-21946
set
2001-12-05 00:08
2002.01.08
Once again work with bases


7-22448
Stanislas
2001-09-11 15:24
2002.01.08
Data on diskette


1-22205
Denis Proshkin
2001-12-15 12:46
2002.01.08
QReport - a lot of data





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 Español 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