Solved

Loading a Resource ??

Posted on 2000-03-15
5
215 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
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 50 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

863 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

21 Experts available now in Live!

Get 1:1 Help Now