Solved

Loading a Resource ??

Posted on 2000-03-15
5
208 Views
Last Modified: 2012-05-04
I'm a belgium student and I have a problem with the resource files.I'm writing an application in VC 6.0 to be able to open files resource (.RES and .H) with the functions 'Finding and Loading Resources' and display it graphically onto the screen. I would like some help, please !
I'm sorry for my english but i'm speak french !
0
Comment
Question by:JulienBelgium
  • 2
  • 2
5 Comments
 
LVL 22

Expert Comment

by:nietod
Comment Utility
I don't think you really want to use a .RES file for this.  . RES file is a compiled resource object file.  Sort of like an .OBJ is a compiled code object file.  Both of these files are intermediate steps to producting a final executble file.  (i.e. these files are not "finished" yet.)

When the final program (and EXE or DLL, for example) is created the information in the .RES file will be included in the final program.  You can then use LoadLibrary() to load the program (EXE or DLL) and FindResource() to find the resources and LoadResource() to actually load the resources.   You can use these functios (and others) on the final EXE or DLL, but not on the .RES file.
0
 
LVL 22

Expert Comment

by:nietod
Comment Utility
Is there a reason you wanted to use the .RES file?  or was that a mistake?
0
 
LVL 5

Expert Comment

by:Wyn
Comment Utility
->I'm writing an application in VC 6.0 to be able to open files resource (.RES and .H) with the functions 'Finding and Loading Resources'
===================================
You'd compile and link resource files and they will emerge into .exe.Then you can use Findxxx,loadxxx,lockxxx to use them...

->FindResource() to find the resources and LoadResource() to actually load the resources.  
=======================
You'd call LockResource() afterwards...
0
 
LVL 5

Accepted Solution

by:
Wyn earned 50 total points
Comment Utility
Here is a sample:

For example, the following PlayResource function plays a specified WAVE resource.

BOOL PlayResource(LPSTR lpName)
{
    BOOL bRtn;
    LPSTR lpRes;
    HANDLE hResInfo, hRes;
 
    // Find the WAVE resource.
 
    hResInfo = FindResource(hInst, lpName, "WAVE");
    if (hResInfo == NULL)
        return FALSE;
 
    // Load the WAVE resource.
 
    hRes = LoadResource(hInst, hResInfo);
    if (hRes == NULL)
        return FALSE;
 
    // Lock the WAVE resource and play it.
 
    lpRes = LockResource(hRes);
    if (lpRes != NULL) {
        bRtn = sndPlaySound(lpRes, SND_MEMORY | SND_SYNC |
            SND_NODEFAULT);
        UnlockResource(hRes);
    }
    else
        bRtn = 0;
 
    // Free the WAVE resource and return success or failure.
 
    FreeResource(hRes);
    return bRtn;
}


In the .RC file, define the WAVE resource.

MYWAVE    WAVE    "wavefile.wav"



Regards
W.Yinan
0
 

Author Comment

by:JulienBelgium
Comment Utility
I'm happy for your help but I'm student and this work that for my school !
I would like a listing for your similar application,please,please,please !!!
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
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.

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

12 Experts available now in Live!

Get 1:1 Help Now