Solved

Read/Write resources...

Posted on 1998-05-11
4
186 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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 shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

821 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