Problem while trying to add XP manifest to a compiled exe

Hi,

I want to add XP manifest to a compiled exe,

I'm using this code:

-----------------------------------------------------------
function ReadFilePoke(FileName: string): widestring;
var
  F:      file;
  Buffer: widestring;
  Size:   integer;
  ReadBytes: integer;
  DefaultFileMode: byte;
begin
  Result := '';

  DefaultFileMode := FileMode;

  FileMode := 0;
  AssignFile(F, FileName);
  Reset(F, 1);

  if (IOResult = 0) then
  begin
    Size := FileSize(F);

    while (Size > 1024) do
    begin
      SetLength(Buffer, 1024);
      BlockRead(F, Buffer[1], 1024, ReadBytes);
      Result := Result + Buffer;
      Dec(Size, ReadBytes);
    end;

    SetLength(Buffer, Size);
    BlockRead(F, Buffer[1], Size);
    Result := Result + Buffer;

    CloseFile(F);
  end;

  FileMode := DefaultFileMode;
end;


procedure TForm1.Button1Click(Sender: TObject);
var
buffer: widestring;
update : dword;
begin

  buffer := readfilepoke('C:\man.txt');
   update := BeginUpdateResource('C:\man.exe', false);
  if update <> 0 then
    try
      UpdateResource(update, MAKEINTRESOURCE(24), '1', 0, @buffer[1], length(buffer));
    finally
      EndUpdateResource(update, false);
    end;

end;
-----------------------------------------------------------

man.exe is the file without manifest,
man.txt is my file containing manifest:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
   <assemblyIdentity
      name="Microsoft.Windows.MyCoolApp"
      processorArchitecture="x86"
      version="5.1.2600.0"
      type="win32"/>
   <description>Application description here</description>
   <dependency>
      <dependentAssembly>
         <assemblyIdentity
            type="win32"
            name="Microsoft.Windows.Common-Controls"
            version="6.0.0.0"
            processorArchitecture="x86"
            publicKeyToken="6595b64144ccf1df"
            language="*"
         />
      </dependentAssembly>
   </dependency>
</assembly>




when I check with a resource editor, everything seems fine!
even if for example, I remove the manifest of calc.exe, then add it again (the exact manifest) with my code, when I compare both file using resource editor, it's the samething! i cant see any difference, but when I execute both, one has the xp look, and the other one doesn't,

I really don't understand!


NOTE that I don't want to add manifest on my own project, I already know how, what I want to do is to be able to add manifest on any already compiled exe


thx in advance!

500 points for this

Marc582Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

2266180Commented:
you're incorrectly using "1" there as the name. you should be using MAKEINTRESOURCE(1)
also make sure you are using the correct language for your system locale.
and I don't understand why you are using widestring as a buffer. the XML is ascii. the encoding of the values from it are UTF-8.
I have to run for a few hours, but if yuo cannot fix it, I'll make a demo for you.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Marc582Author Commented:
thx!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.