source: trunk/src/kernel32/resource.cpp@ 1872

Last change on this file since 1872 was 1872, checked in by bird, 26 years ago

Implemented EnumResourceNamesA/W.

File size: 5.6 KB
Line 
1/* $Id: resource.cpp,v 1.10 1999-11-29 00:04:05 bird 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//******************************************************************************
24HRSRC WIN32API FindResourceA(HINSTANCE hModule, LPCSTR lpszName, LPCSTR lpszType)
25{
26 Win32ImageBase *module;
27
28 dprintf(("FindResourceA %X", hModule));
29 module = Win32ImageBase::findModule(hModule);
30 if(module == NULL)
31 return(NULL);
32
33 return module->findResourceA(lpszName, (LPSTR)lpszType);
34}
35//******************************************************************************
36//******************************************************************************
37HRSRC WIN32API FindResourceW(HINSTANCE hModule, LPCWSTR lpszName,
38 LPCWSTR lpszType)
39{
40 Win32ImageBase *module;
41
42 dprintf(("FindResourceW %X", hModule));
43 module = Win32ImageBase::findModule(hModule);
44 if(module == NULL)
45 return(NULL);
46
47 return module->findResourceW((LPWSTR)lpszName, (LPWSTR)lpszType);
48}
49//******************************************************************************
50//hRes returned by LoadResource
51//******************************************************************************
52PVOID WIN32API LockResource(HGLOBAL hRes)
53{
54 return (PVOID)hRes;
55}
56//******************************************************************************
57//hRes == returned by FindResource(Ex)
58//******************************************************************************
59HGLOBAL WIN32API LoadResource(HINSTANCE hModule, HRSRC hRes)
60{
61 Win32Resource *res = (Win32Resource *)hRes;
62
63 dprintf(("LoadResource %x %X\n", hModule, hRes));
64
65 /* @@@PH */
66 if (HIWORD(res) == NULL) {
67 dprintf(("LoadResource %x: invalid hRes %x", hModule, hRes));
68 return 0;
69 }
70 else return (HGLOBAL)res->lockResource();
71}
72//******************************************************************************
73//hRes == returned by FindResource(Ex)
74//******************************************************************************
75DWORD WIN32API SizeofResource(HINSTANCE hModule, HRSRC hRes)
76{
77 Win32Resource *res = (Win32Resource *)hRes;
78
79 dprintf(("OS2SizeofResource\n"));
80 if(res == NULL)
81 return(0);
82
83 return res->getSize();
84}
85//******************************************************************************
86
87
88
89/**
90 * The EnumResourceNames function searches a module for each
91 * resource of the specified type and passes the name of each
92 * resource it locates to an application-defined callback function
93 *
94 * @returns If the function succeeds, the return value is nonzero.
95 * If the function fails, the return value is zero
96 * @param hModule resource-module handling
97 * @param lpszType pointer to resource type
98 * @param lpEnumFunc pointer to callback function
99 * @param lParam application-defined parameter
100 * @status stub
101 * @author knut st. osmundsen
102 * @remark The EnumResourceNames function continues to enumerate resource
103 * names until the callback function returns FALSE or all resource
104 * names have been enumerated
105 */
106BOOL WIN32API EnumResourceNamesA(HINSTANCE hModule,
107 LPCTSTR lpszType,
108 ENUMRESNAMEPROCA lpEnumFunc,
109 LONG lParam)
110{
111 Win32ImageBase *pModule;
112
113 dprintf(("KERNEL32:EnumResourceNamesA(%08x,%08x,%08x,%08x) not implemented\n",
114 hModule, lpszType, lpEnumFunc, lParam
115 ));
116
117 pModule = Win32ImageBase::findModule(hModule);
118 if (pModule == NULL)
119 {
120 SetLastError(ERROR_RESOURCE_DATA_NOT_FOUND);
121 return FALSE;
122 }
123
124 return pModule->enumResourceNamesA(hModule, lpszType, lpEnumFunc, lParam);
125}
126
127
128/**
129 * The EnumResourceNames function searches a module for each
130 * resource of the specified type and passes the name of each
131 * resource it locates to an application-defined callback function
132 *
133 * @returns If the function succeeds, the return value is nonzero.
134 * If the function fails, the return value is zero
135 * @param hModule resource-module handling
136 * @param lpszType pointer to resource type
137 * @param lpEnumFunc pointer to callback function
138 * @param lParam application-defined parameter
139 * @status stub
140 * @author knut st. osmundsen
141 * @remark The EnumResourceNames function continues to enumerate resource
142 * names until the callback function returns FALSE or all resource
143 * names have been enumerated
144 */
145BOOL WIN32API EnumResourceNamesW(HMODULE hModule,
146 LPCWSTR lpszType,
147 ENUMRESNAMEPROCW lpEnumFunc,
148 LONG lParam)
149{
150 Win32ImageBase *pModule;
151
152 dprintf(("KERNEL32:EnumResourceNamesW(%08x,%08x,%08x,%08x)\n",
153 hModule, lpszType, lpEnumFunc, lParam));
154
155 pModule = Win32ImageBase::findModule(hModule);
156 if (pModule == NULL)
157 {
158 SetLastError(ERROR_RESOURCE_DATA_NOT_FOUND);
159 return FALSE;
160 }
161
162 return pModule->enumResourceNamesW(hModule, lpszType, lpEnumFunc, lParam);
163}
164
Note: See TracBrowser for help on using the repository browser.