Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Read/Write resources...

Posted on 1998-05-11
4
Medium Priority
?
209 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 22

Accepted Solution

by:
nietod earned 400 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
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 learn how to clear a vector as well as how to detect empty vectors in C++.

718 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