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
Solved

Loading a Resource ??

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
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. …
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 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…

839 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