| 1 | /* $Id: resource.cpp,v 1.9 1999-09-15 23:38:01 sandervl Exp $ */
|
|---|
| 2 |
|
|---|
| 3 | /*
|
|---|
| 4 | * Misc resource procedures
|
|---|
| 5 | *
|
|---|
| 6 | * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl)
|
|---|
| 7 | * Copyright 1998 Patrick Haller
|
|---|
| 8 | *
|
|---|
| 9 | *
|
|---|
| 10 | * Project Odin Software License can be found in LICENSE.TXT
|
|---|
| 11 | *
|
|---|
| 12 | */
|
|---|
| 13 | #include <os2win.h>
|
|---|
| 14 | #include <unicode.h>
|
|---|
| 15 | #include "winres.h"
|
|---|
| 16 | #include <winimagebase.h>
|
|---|
| 17 | #include <winexebase.h>
|
|---|
| 18 | #include <windllbase.h>
|
|---|
| 19 |
|
|---|
| 20 | //******************************************************************************
|
|---|
| 21 | //lpszName = integer id (high word 0), else string (name or "#237")
|
|---|
| 22 | //Can lpszType contain a pointer to a default resource type name?
|
|---|
| 23 | //******************************************************************************
|
|---|
| 24 | HRSRC WIN32API FindResourceA(HINSTANCE hModule, LPCSTR lpszName, LPCSTR lpszType)
|
|---|
| 25 | {
|
|---|
| 26 | Win32ImageBase *module;
|
|---|
| 27 |
|
|---|
| 28 | dprintf(("FindResourceA %X", hModule));
|
|---|
| 29 | if(hModule == 0 || hModule == -1 || (WinExe != NULL && hModule ==
|
|---|
| 30 | WinExe->getInstanceHandle()))
|
|---|
| 31 | {
|
|---|
| 32 | module = (Win32ImageBase *)WinExe;
|
|---|
| 33 | }
|
|---|
| 34 | else module = (Win32ImageBase *)Win32DllBase::findModule(hModule);
|
|---|
| 35 |
|
|---|
| 36 | if(module == NULL)
|
|---|
| 37 | return(NULL);
|
|---|
| 38 |
|
|---|
| 39 | return module->findResourceA(lpszName, (LPSTR)lpszType);
|
|---|
| 40 | }
|
|---|
| 41 | //******************************************************************************
|
|---|
| 42 | //******************************************************************************
|
|---|
| 43 | HRSRC WIN32API FindResourceW(HINSTANCE hModule, LPCWSTR lpszName,
|
|---|
| 44 | LPCWSTR lpszType)
|
|---|
| 45 | {
|
|---|
| 46 | Win32ImageBase *module;
|
|---|
| 47 |
|
|---|
| 48 | dprintf(("FindResourceW %X", hModule));
|
|---|
| 49 | if(hModule == 0 || hModule == -1 || (WinExe != NULL && hModule ==
|
|---|
| 50 | WinExe->getInstanceHandle()))
|
|---|
| 51 | {
|
|---|
| 52 | module = (Win32ImageBase *)WinExe;
|
|---|
| 53 | }
|
|---|
| 54 | else module = (Win32ImageBase *)Win32DllBase::findModule(hModule);
|
|---|
| 55 |
|
|---|
| 56 | if(module == NULL)
|
|---|
| 57 | return(NULL);
|
|---|
| 58 |
|
|---|
| 59 | return module->findResourceW((LPWSTR)lpszName, (LPWSTR)lpszType);
|
|---|
| 60 | }
|
|---|
| 61 | //******************************************************************************
|
|---|
| 62 | //hRes returned by LoadResource
|
|---|
| 63 | //******************************************************************************
|
|---|
| 64 | PVOID WIN32API LockResource(HGLOBAL hRes)
|
|---|
| 65 | {
|
|---|
| 66 | return (PVOID)hRes;
|
|---|
| 67 | }
|
|---|
| 68 | //******************************************************************************
|
|---|
| 69 | //hRes == returned by FindResource(Ex)
|
|---|
| 70 | //******************************************************************************
|
|---|
| 71 | HGLOBAL WIN32API LoadResource(HINSTANCE hModule, HRSRC hRes)
|
|---|
| 72 | {
|
|---|
| 73 | Win32Resource *res = (Win32Resource *)hRes;
|
|---|
| 74 |
|
|---|
| 75 | dprintf(("LoadResource %x %X\n", hModule, hRes));
|
|---|
| 76 |
|
|---|
| 77 | /* @@@PH */
|
|---|
| 78 | if (HIWORD(res) == NULL) {
|
|---|
| 79 | dprintf(("LoadResource %x: invalid hRes %x", hModule, hRes));
|
|---|
| 80 | return 0;
|
|---|
| 81 | }
|
|---|
| 82 | else return (HGLOBAL)res->lockResource();
|
|---|
| 83 | }
|
|---|
| 84 | //******************************************************************************
|
|---|
| 85 | //hRes == returned by FindResource(Ex)
|
|---|
| 86 | //******************************************************************************
|
|---|
| 87 | DWORD WIN32API SizeofResource(HINSTANCE hModule, HRSRC hRes)
|
|---|
| 88 | {
|
|---|
| 89 | Win32Resource *res = (Win32Resource *)hRes;
|
|---|
| 90 |
|
|---|
| 91 | dprintf(("OS2SizeofResource\n"));
|
|---|
| 92 | if(res == NULL)
|
|---|
| 93 | return(0);
|
|---|
| 94 |
|
|---|
| 95 | return res->getSize();
|
|---|
| 96 | }
|
|---|
| 97 | //******************************************************************************
|
|---|
| 98 | //******************************************************************************
|
|---|
| 99 | BOOL WIN32API EnumResourceNamesA(HINSTANCE hModule, LPCTSTR lpszType,
|
|---|
| 100 | ENUMRESNAMEPROCA lpEnumFunc, LONG lParam)
|
|---|
| 101 | {
|
|---|
| 102 | dprintf(("OS2EnumResourceNamesA - stub\n"));
|
|---|
| 103 | return(FALSE);
|
|---|
| 104 | }
|
|---|
| 105 | //******************************************************************************
|
|---|
| 106 | //******************************************************************************
|
|---|