?
Solved

Loading a Resource ??

Posted on 2000-03-15
5
Medium Priority
?
246 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
[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
  • 2
  • 2
5 Comments
 
LVL 22

Expert Comment

by:nietod
ID: 2619421
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
ID: 2619424
Is there a reason you wanted to use the .RES file?  or was that a mistake?
0
 
LVL 5

Expert Comment

by:Wyn
ID: 2620133
->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 150 total points
ID: 2620148
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
ID: 2627187
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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

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…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

752 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