Solved

Read/Write resources...

Posted on 1998-05-11
4
160 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
Comment Utility
Answer coming.
0
 
LVL 22

Expert Comment

by:nietod
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
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.

762 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

13 Experts available now in Live!

Get 1:1 Help Now