Solved

Using a resource editor as offline configuration tool

Posted on 2000-05-14
28
208 Views
Last Modified: 2013-11-20
I'm considering implementing ay objects as persistable. (All settings are properties).
In that case, it should be rather easy to load and save the objects into a file that resembles the DevStudio's resource file.

This leaves me with the question:
How can I cause my system to load the configuration stored in a resource file? Is there a known COM object that does this?
(I would like to avoid "reverse enjeneering" the format).
0
Comment
Question by:shaig
  • 13
  • 12
  • 2
  • +1
28 Comments
 
LVL 10

Expert Comment

by:RONSLOW
Comment Utility
Under WinNT you are allowed to edit resource files from within a program.  Under Win95/98 that is not possible (you cannot write back to your execuatble).

How about you use the registry instead?  Or a separate file (eg. a .INI file).
0
 
LVL 3

Author Comment

by:shaig
Comment Utility
I ment the .RC file, not the exe.
I can settle also for the VB .frm files.
0
 
LVL 4

Expert Comment

by:captainkirk
Comment Utility
If you want your objects to persist, make them COM objects that supports IPersist and one or more of its derived interfaces: IPersistStreamInit, IPersistStream, and IPersistStorage. It's a bit complex to discuss in detail here, but there is enough documentation in MSDN to get you through it...
0
 
LVL 3

Author Comment

by:shaig
Comment Utility
It's rather easy to make an object persistable, this is not what i'm asking.
I am talking about the STORAGE! I want a text file storage.
0
 
LVL 10

Expert Comment

by:RONSLOW
Comment Utility
The answer is "You cannot".

..RC files are not supported by the SDK (it doesn't know anyhting about them), it is just a source file that the resource compiler understands when it compiles into a .RES.  The format is not really extensible (except that you can add your own hex data as a resource).

You'll have to do it yourself.

The best way is with a .INI file, as Win32 has API's for reading and writing this and it has (some) structure).


0
 
LVL 3

Expert Comment

by:SamHobbs
Comment Utility
Instead of saying "You cannot" I think people should be asking for clarification of the requirements. The specification here is so vague that it is difficlut to determine what you are asking for, so I think it is not possible to say it can't be done. Unless it can be understood what it is, it is not possible to know if it is possible.
0
 
LVL 3

Author Comment

by:shaig
Comment Utility
Sorry, Don't think it's vague. I do think RONSLOW understood what i'm talking about.

I mentioned several formats that will do the work for me.

I rejected the answer because it is done with visual basic FRM files as well.

I am currently working on implementing a registry storage that will do the work. But this is irelevant for the question.

0
 
LVL 10

Expert Comment

by:RONSLOW
Comment Utility
If your data is specified in a .RC file as (HEX) binary data, then you can load it into the program just like any other resource (bitmap, icon, wave, string table etc etc)

As a binary, it can have any format .. including text. You just read in a lump and do whatever you want with it. That is directly supported in the SDK.

However, you cannot write info back to the resource programmatically.  They are read only (except under WinNT).  If load only is OK, then use a resource.

Also the resource needs to be compiled from .RC to .RES and then (usually) linked into your exe (sometimes in a separate resource DLL, that's what I do)

For persistence, most COM object wil persist to a storage (usually associated with a disk file).  You can implement that to write as text.  Property sets are useful forms of persitence, if there is not much structure in the data.  I use them for storing extra info with my data files.  INI files are also good, and supported by the SDK for read and write.

Also very popular as a text format is XML.  This is being better supported in windows lately.  Some com and database objects etc support load/save to/from XML.  Also the IE control handles it .. it is similar in HTML.

You can put HTML (and XML) in a resource.

0
 
LVL 3

Author Comment

by:shaig
Comment Utility
I know INI files, this is not what i'm looking for. If i'll have to settle for something it will be the registry format (which is also hirarchical).

Anyway, a vb frm file will be just exellent. Using it will enable me to load an frm file in vb and then use property sheets to configur my components. the frm file is textual as well.


0
 
LVL 10

Expert Comment

by:RONSLOW
Comment Utility
But aren't you using MFC?

How will a VB form help?

How will you load it into your MFC app?

0
 
LVL 10

Expert Comment

by:RONSLOW
Comment Utility
And how does this address your original question?
0
 
LVL 3

Author Comment

by:shaig
Comment Utility
If this would be a com object it wouldn't really matter. It need to be a com solution from the obvious reason that it persists com objects.
VB has a resource editor just like vc.

I know how to persist into text files, I just want a cool thing that will enable me to work with one of the DevStudio's editors.

0
 
LVL 10

Expert Comment

by:RONSLOW
Comment Utility
Your question here was:

"How can I cause my system to load the configuration stored in a resource file? Is there a known COM object that does this?"

I answered this, saying that you can't and there isn't.  But gave you some alternatives to try.

You say: "It's rather easy to make an object persistable, this is not what i'm asking.  I am talking about the STORAGE! I want a text file storage."

But you can use text files as storage for persistable objects.

You say that you "rejected the answer because it is done with visual basic FRM files as well."

That comment makes no sense.  The answer didn't even mention VB forms.  What have they got to do with the question or the answer?

Your last comment makes it even more confusing.  You imply that you've got COM objects, then that you don't.  You mention that VB has a resrouce editor (so what?).  You say you KNOW how to persist text files (the why did you ask), and talk about some 'cool thing'.

I think I have answered the question you posed.

If not, then what the hell is it you want to know, because it certainly isn't obvious at all what you are trying to do or what you want to know. If there is something else you need to know, accept the answer for this and ask another question.

0
 
LVL 3

Expert Comment

by:SamHobbs
Comment Utility
I think he does not know what he really wants and so the original question was vague. I would try to clarify the requirements before offering an answer initially. On Friday, May 26, shaig said "I do think RONSLOW understood what i'm talking about" but it seems that that is not entirely true. I think that shaig needs to understand that the question is vague. I agree with RONSLOW that he has done the best he can with the specifications provided.

0
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

 
LVL 3

Author Comment

by:shaig
Comment Utility
SamHobbs:
RONSLOW did understand the issue at hand, the solutions were relevant, but just not good enough. I'm sorry that you did not follow as he did.

Dear RONSLOW,
First I'd like to thank you for the time and trouble you spent on this question.
Now, I mentioned that I would like to use a DevStudio as a resource editor (I did not mention if it would be vc or vb, they both have one - If vc does a crapy work then I'd like to use vb).
I can accept your answer since technicaly it does the work, the thing is: it doesn't help me. I wanted something that will work with DevStudio. I have better alternatives then the ones you've suggested, such as a registry storage (can be dumped to text later, etc.).
I don't mind giving the points, I don't maind even getting the blame for being not clear enough (sorry, English is not my speaking language), but I'd rather get your help on the thing i'm trying to accomplish.
Thanks, shaig.

0
 
LVL 10

Expert Comment

by:RONSLOW
Comment Utility
>Dear RONSLOW,
>First I'd like to thank you for the time and trouble you spent on this
>question.

Welcome

>Now, I mentioned that I would like to use a DevStudio as a resource editor (I
>did not mention if it would be vc or vb, they both have one

In an MFC area such as this, DevStudio would certainly imply the VC++ DevStudio, rather than the VB one (which has always been separate).

That certainly seemed reasonable.

In any case, you wanted something like an .rc files and to be able to read and write and wanted something that is supported.  That really means registry or .ini files (or perisiting objects whcih you said was no good)

>If vc does a crapy work then I'd like to use vb).

VC editor is a good resrouce editor.

>I can accept your answer since technicaly it does the work, the thing
>is: it doesn't help me. I wanted something that will work with
>DevStudio.

You said you wanted your system to load and save resource files (or at least a text format).  You didn't say you wanted the solution to work with DevStudio.

>I have better alternatives then the ones you've suggested, such as
>a registry storage (can be dumped to text later, etc.).

The WAS one of MY suggestions.

But you said it HAD to be text, so I didn't follow that any further.

>I don't mind giving the points, I don't maind even getting the blame for
>being not clear enough (sorry, English is not my speaking language), but I'd
>rather get your help on the thing i'm trying to accomplish.

To get help, you need to be clearer about what it is you are trying to do.  A more general indication would be good, rather than focusing on details that may  or mat not be the best way to accomplish your overall goals.

What is it you actually want to be able to do in the end?

0
 
LVL 3

Author Comment

by:shaig
Comment Utility
I accept your comments.
I don't know how to refraise this and don't know any other section to put it in (maybe Windows programming), but i'll try again:
I want to be able to load a storage file into a perferably smart editor like DevStudio (vb or vc), in order to edit my system configuration: this way I can use the ole property pages of my objects to configure. After i'm done configuring, i'd like my system to be able to load those files and persist the objects in run-time.
I like DevStudio formats from another reason, they can be edited (when push comes to shove), by a text editor as well.  (I defenetly don't wan't to modify the binary)

This is a COM+ application where i store configuration per class: all objects of a given class share the same configuration.

I hope this is clearer, if clearification are needed, let me know.
0
 
LVL 10

Expert Comment

by:RONSLOW
Comment Utility
Your objects simply need to persist themselves to a text file (stream). provide an IPersistStream interface that does what you want (I'd suggest INI file format for named properties)

Then the objects can display their property pages when you want to configure them (in whatever client you're putting them in), and you'll still get a text file that you can edit by hand (and there is a nice free INI file editor that looks like RegEdit for 'hand' editing the files).

I hope I understand what you're wanting here.

0
 
LVL 3

Author Comment

by:shaig
Comment Utility
Not exactly. I'd like to avoid both writing the client and the text storage, thats the whole idea.
If it gets down to that, i'd rather use the registry format which is much more flexible.


You understand just fine, I'm just afraid that the cool solution i hoped for, cannot be implemented due to lack of documantation.

:-(

0
 
LVL 10

Expert Comment

by:RONSLOW
Comment Utility
You shouldn't need to (re)write the client.

What I'm suggesting is that you need to tell the COM object how you want it to read/write itself to a stream.  eg. write it out in a text file format.

The editing of OLE property pages should be able to be done in whatever client you are using (eg VC or VB).  The question is what/how/where the information about it is read/written.
0
 
LVL 3

Author Comment

by:shaig
Comment Utility
Not accurate:
The interface for opening property pages is not straight forward as you'd expect, it is implemented by activex containers that support design time activation, unfortunatly not many containers do that: DevStudio does, but not a client. Besides, adding a new type of object will force me to run DevStudio anyway so the client will be able to invoke it.


I hope i'm not boring you out here, it's just that being able to do this thing will do this application a real service.
0
 
LVL 10

Expert Comment

by:RONSLOW
Comment Utility
But didn't you alread say that you were going to use DevStudio for modifying the object properties (using COM).

In which case it boils down to persisting to a human-readable format.

As I suggested a few times :-), INI format is a good text file format for properties, especially when you use an INI-file editor.  And its also fairly readable even in a text editor.

But as long as you can edit the properties in DevStudio directly via the property pages, the file format used to persist them shouldn't matter all that much.
0
 
LVL 3

Author Comment

by:shaig
Comment Utility
I'm probably missing something:
The format of the text file should be exactly as DevStudio writes to a file, otherwise it is of no use. In this case, why do i need a client app for?
The motivation is not to compile the system every time I change a property (just when I add or remove objects). Is this clear?
0
 
LVL 10

Expert Comment

by:RONSLOW
Comment Utility
Lets take a step back.

You don't seem to be making a lot of sense (to me) here.  We really need a whiteboard that we can draw pictures on to explain what we are each talking about.

What are there objects and where / how are the used?  And where / how do you want to modify them?

Are you talking about reading/writing the format of a dialog?  This is possible, but not in DevStudio .rc format unless you want to reverse engineer that.  However, you can get load a (compiled) dialog resource template, and then write it out in whatever format you want, reload it at a later time and re-create the dialog template from that.

0
 
LVL 3

Author Comment

by:shaig
Comment Utility
Dear RONSLOW,
I will award you with the points.
It looks like vb does what i'm looking for, but it isn't documented.
I thank you for the time. I guess the first "you can't" answer you've posted was the closest one...
I don't feel like reverse enjeneering (like mentioned in question), so i'll just skip this feature.


0
 
LVL 10

Accepted Solution

by:
RONSLOW earned 300 total points
Comment Utility
Good luck.  The main thing is you have found some sort of solution for your problem.  Just wish I fully understood what that problem was :-).

Thanks
0
 
LVL 3

Author Comment

by:shaig
Comment Utility
Using a resource editor as an offline cfg editor.
0
 
LVL 3

Author Comment

by:shaig
Comment Utility
Answer accepted
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

763 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

11 Experts available now in Live!

Get 1:1 Help Now