madRes - UpdateResourceW (AV)

delphi package - madRes, madTools, madStrings, ...
Post Reply
Hybris
Posts: 3
Joined: Thu Feb 09, 2006 4:30 pm

madRes - UpdateResourceW (AV)

Post by Hybris »

I'd like to add an XP MANIFEST to some executables using MadRes:

Code: Select all

  upd := BeginUpdateResourceW(PWideChar(WideString(f)), false);
  if upd <> 0 then
       begin
        if UpdateResourceW(upd,  MAKEINTRESOURCEW(24), MAKEINTRESOURCEW(1), 0, Res.Memory, Res.Size) then
          Items[i].SubItems[0] := XP else Items[i].SubItems[0] := ERR;
        EndUpdateResource(upd, false);
       end;
but I step into an Access Violation in UpdateResourceW:

Code: Select all

 if update <> 0 then
    try
      with TPResourceHandle(update)^ do begin
        ppr1 := FindDir(tree, type_); <--- ERROR!
        if ppr1^ <> nil then begin
Is it a fault of mine?! :-x

Thank you in advance
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

Make sure you're using the madRes APIs and not the Windows APIs. You can do so by adding a "madRes." before the API names. Does that help?
Hybris
Posts: 3
Joined: Thu Feb 09, 2006 4:30 pm

Post by Hybris »

I already had madRes before the API names, so it doesn't help. :sorry: Anyway I solved my problem switching to Resource Utilities (http://www.wilsonc.demon.co.uk/d10resourceutils.htm).

Thank you!
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

I'm glad you got the problem solved with Colin's stuff. Still I'd like to find out why madRes failed for you. Would you mind sending me a little demo project which reproduces the problem? Or would you at least send me one of the exes you tried to modified together with the manifest you tried to add?

Thanks!
Hybris
Posts: 3
Joined: Thu Feb 09, 2006 4:30 pm

Post by Hybris »

Would you mind sending me a little demo project which reproduces the problem?
I'm really sorry but I deleted my MadRes project, I kept only the working one. :sorry: Anyway I tried with a standard Manifest (it works smoothly using Colin's units) and my code is showed by the original post.
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

Just tried to reproduce it, but I can't. It works just fine for me. The exception location very strongly indicates that the "upd" handle you gave into UpdateResourceW was not what madRes expected. I can only understand that if for whatever reason you used Windows.BeginUpdateResourceW together with madRes.UpdateResourceW.

Anyway, don't worry, just forget it. I simply wanted to put a last message into this thread in case somebody runs into a similar problem.
Post Reply