Click to See Complete Forum and Search --> : Resources


Andrew Truckle
April 12th, 1999, 08:29 AM
If I add a file as a internal resource with say ID_MYFILE

how can I convert this resource into a string suitable for passing to a function which previously required a path to a file? Can it be done?

real name
April 12th, 1999, 08:45 AM
do you mean CString((LPCSTR)ID_) constructor or CString::LoadString() functionality?
t!

Andrew Truckle
April 12th, 1999, 08:50 AM
You tell me!

I have a function FunctionLoadInit(char *pathtofile)

At the moment I pass a string.

I though I might be able to insert the file as a resource, give it an ID and somehow use this as the parameter, but it must be a string.

I am trying to avoid having to issue a seperate file with my program, thats all.

real name
April 12th, 1999, 09:08 AM
maybe i still do not understand (why cathegory dialog?)
you want read data from resource given by its name (string)
try to look ak FindResource and LoadResource funtions (RT_RCDATA?)
maybe this helps you
t!

Andrew Truckle
April 12th, 1999, 09:12 AM
Hi

I put in in this category because I am doing a dialog based application.

The embeded resource needs to be treated as it it were a standard file.

For example, if you embed a BITMAP, you can use MAKEINTRESOURCE

Gomez Addams
April 12th, 1999, 11:48 AM
If the contents of the file can be treated as a standard resource you can do this.
Another way to look at this is if you can imbed your file in the resource script as a
string then a call to LoadString should work. I doubt any of the other resource types
would be very helpful. Watch out for binary data in the file - could cause difficulties.
Just give the file an id like any other resource and pass this to the LoadString member
of a CString object.

April 12th, 1999, 07:43 PM
Do you want the contents of the file or the name of the file in the resource?

Andrew Truckle
April 13th, 1999, 01:18 AM
Hi

I want the contents of the file.

Basically, I want to add the binary file as a resource, therefore it is embeded in the program, but I then need some way of accessing this data as a binary file.

I could use LoadResource/FindResource to get a HGLOBAL, but I don't have a clue of how to treat this as the equivalent of a binary file stream with read/write facilities.

Any ideas?