5 Replies - 600 Views - Last Post: 05 July 2013 - 06:34 PM Rate Topic: -----

#1 Ahmedn1  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 23
  • View blog
  • Posts: 557
  • Joined: 04-August 09

Delphi: BeginUpdateResourceW always returns 0

Posted 04 July 2013 - 12:01 AM

I have this function in Delphi (I'm new to Delphi):

function WriteSettings(ServerFile: PWideChar; Settings: TConfiguracoes; xResourceName: pWideChar = nil): boolean;
var
  ResourceHandle: THandle;
begin
  if xResourceName = nil  then xResourceName := ResourceName;
  Result := False;

  ResourceHandle := BeginUpdateResourceW(ServerFile, False);
  if ResourceHandle <> 0 then
  begin
    Result := UpdateResourceW(ResourceHandle, MakeIntResourceW(10), PWideChar(xResourceName), 0, @Settings, SizeOf(TConfiguracoes));
    if Result then Result := EndUpdateResource(ResourceHandle, False);
  end;
end;



and it doesn't work because the "BeginUpdateResourceW" always returns 0

why is that ?

I'm using Win 8 64-bit
and working on Delphi XE

Is This A Good Question/Topic? 0
  • +

Replies To: Delphi: BeginUpdateResourceW always returns 0

#2 #define  Icon User is offline

  • Duke of Err
  • member icon

Reputation: 1369
  • View blog
  • Posts: 4,737
  • Joined: 19-February 09

Re: Delphi: BeginUpdateResourceW always returns 0

Posted 04 July 2013 - 06:20 PM

Hi, perhaps it could be access to the file?

how to store settings in resource

Can you use the GetLastError function?

BeginUpdateResource

GetLastError
Was This Post Helpful? 0
  • +
  • -

#3 Ahmedn1  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 23
  • View blog
  • Posts: 557
  • Joined: 04-August 09

Re: Delphi: BeginUpdateResourceW always returns 0

Posted 04 July 2013 - 06:34 PM

View Post#define, on 05 July 2013 - 03:20 AM, said:

Hi, perhaps it could be access to the file?

how to store settings in resource

Can you use the GetLastError function?

BeginUpdateResource

GetLastError


I think the problem was in the exe file
when I tried to run it I got an error message
Was This Post Helpful? 0
  • +
  • -

#4 GunnerInc  Icon User is offline

  • "Hurry up and wait"
  • member icon




Reputation: 858
  • View blog
  • Posts: 2,286
  • Joined: 28-March 11

Re: Delphi: BeginUpdateResourceW always returns 0

Posted 04 July 2013 - 06:55 PM

What error message did you get? Did you use GetLastError as #define mentioned?
Was This Post Helpful? 0
  • +
  • -

#5 Ahmedn1  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 23
  • View blog
  • Posts: 557
  • Joined: 04-August 09

Re: Delphi: BeginUpdateResourceW always returns 0

Posted 04 July 2013 - 08:44 PM

GetLastError returns 0
Was This Post Helpful? 0
  • +
  • -

#6 #define  Icon User is offline

  • Duke of Err
  • member icon

Reputation: 1369
  • View blog
  • Posts: 4,737
  • Joined: 19-February 09

Re: Delphi: BeginUpdateResourceW always returns 0

Posted 05 July 2013 - 06:34 PM

Does it work?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1