Solved

Loading a Resource ??

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
TCP/IP Socket - connection close results in data lost 14 132
Should CArray be used for a list of pointers in C++? 19 102
thread-safe code in c++ 2 98
computer science syllabus 3 81
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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.

813 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