Solved

Read/Write resources...

Posted on 1998-05-11
4
170 Views
Last Modified: 2010-04-10
Hello guys,

I used to develop on Mac and I remember it was possible to Read&Write resources. Applications have a
resource fork and a data fork. I would like now to do the same under windoz so I know how to read a
resource (ex String) but I am not sure it is possible to write it (after modification) and if yes, how to do that.

Can you help me ??

Thanks a lot,
WW
0
Comment
Question by:wwalschaerts
  • 3
4 Comments
 
LVL 22

Accepted Solution

by:
nietod earned 100 total points
ID: 1175665
Answer coming.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1175666
The Mac OS was built from the ground up to support a GUI.  So they could think ahead and designed files with two forks.  The Windows OS has its roots in DOS (which really came from CP/M) so it doesn't support two forks.  The windows resources are imbedded into the EXE file or DLL file by the linker and they are static.  You could actually go an change the information, if you were carefule, but the format of the information is complex and you have to be careful not to overwrite other resources and/or code.  The other think that makes it tough is that when a EXE or DLL is loaded, the file is open read-only.  So you can change the resources if a file, but only from a seperate program.  That is a EXE can change another EXE or DLL, but not its self.  If you really needed to modify resources, the  best way would be to modify ones in a DLL and then load the DLL with LoadLibrary to access the new resources in it.  However, there is usually no need to modify resources in windows.  Especially now that there is the registry.  I hope this helps.
0
 
LVL 10

Expert Comment

by:RONSLOW
ID: 1175667
Win95 does not support updating resources of an exe or dll.  You can only do this under WinNT.

Win32 (on NT) has quite good APIs for updating resources.

The BeginUpdateResource function creates an update handle for the executable file whose resources are to be changed. You must have write access to the executable, so it cannot be already executing.  The UpdateResource function uses this handle to add, delete, or replace a resource in the executable file. The EndUpdateResource function closes the handle.

After an update handle to an executable file is created by BeginUpdateResource, an application can use UpdateResource repeatedly to make changes to the resource data. Each call to UpdateResource contributes to an internal list of additions, deletions, and replacements but does not actually write the data to the executable file. Immediately before closing the update handle, EndUpdateResource writes the accumulated changes to the executable file.

However, as I pointed, you CANNOT do this in Win95 .. the APIS's aren't supported.

0
 
LVL 22

Expert Comment

by:nietod
ID: 1175668
That's good to know.

The big problem then (besides the no 95 support) is that the application can't be running.  However you can write to an unloaded DLL and then load the DLL.  When you want to make changes, unload the DLL, write, and load again.  However, as I pointed out, you probably don't need this.  The registry works well for most tasks where you would have written to the resources on the MAC.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now