CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Andrew Truckle Guest

    [RESOLVED] Resources

    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?


  2. #2

    Re: Resources

    do you mean CString((LPCSTR)ID_) constructor or CString::LoadString() functionality?
    t!


  3. #3
    Andrew Truckle Guest

    Re: Resources

    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.


  4. #4

    Re: Resources

    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!


  5. #5
    Andrew Truckle Guest

    Re: Resources

    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


  6. #6
    Join Date
    May 1999
    Location
    Oregon, USA
    Posts
    302

    Re: Resources

    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.



  7. #7
    Guest

    Re: Resources

    Do you want the contents of the file or the name of the file in the resource?


  8. #8
    Andrew Truckle Guest

    Re: Resources

    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?


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured