|
|
1.1 root 1: Sample: Creating Resource-Only DLLs
2:
3: Summary:
4:
5: The RESDLL sample shows how to create a resource-only
6: dynamic link library (DLL). In short, this is accomplished
7: by creating and resource-compiling a resource (.RC) file,
8: creating and compiling a source code (.C) file containing
9: a simple DLL entry point, and then linking the resulting
10: .RBJ and .OBJ files with the appropriate libraries to
11: create the DLL.
12:
13: The MAIN.EXE program tests THE_DLL.DLL by loading it and
14: referencing the DLL's icon, cursor, and bitmap. The icon
15: and cursor are used by the registered window class, and
16: the bitmap is used in painting the client area.
17:
18: More information:
19:
20: In the preliminary release of Windows NT (July 1992) specifying
21: a DLL entry point for a resource-only DLL was not mandatory,
22: and the version of this sample included with the preliminary SDK
23: did not contain a DLL entry point.
24:
25: This has changed with the Beta release of Windows NT however,
26: and resource-only DLLs are required to have an entry point.
27: What follows is a very simple .C file and an updated MAKEFILE
28: which can be cut out and used with the existing files to
29: create valid .EXE & .DLL files:
30:
31:
32: snip! (THE_DLL.C)
33: o /
34: -----------------------x----------------------------------------------------
35: o \
36:
37:
38: /**************************************************************************\
39: *
40: * MODULE: THE_DLL.C
41: *
42: * PURPOSE: To provide the required (simple) entry point for a resource-
43: * only DLL.
44: *
45: * FUNCTIONS: DLLEntryPoint() - DLL entry point
46: *
47: * Microsoft Developer Support
48: * Copyright (c) 1992 Microsoft Corporation
49: *
50: \**************************************************************************/
51:
52: #include <windows.h>
53:
54:
55:
56: /**************************************************************************\
57: *
58: * FUNCTION: DLLEntryPoint
59: *
60: * INPUTS: hDLL - handle of DLL
61: * dwReason - indicates why DLL called
62: * lpReserved - reserved
63: *
64: * RETURNS: TRUE (always, in this example.)
65: *
66: * Note that the retuRn value is used only when
67: * dwReason = DLL_PROCESS_ATTACH.
68: *
69: * Normally the function would return TRUE if DLL initial-
70: * ization succeeded, or FALSE it it failed.
71: *
72: \**************************************************************************/
73:
74: BOOL WINAPI DLLEntryPoint (HANDLE hDLL, DWORD dwReason, LPVOID lpReserved)
75: {
76: return TRUE;
77: }
78:
79:
80: snip! (updated MAKEFILE)
81: o /
82: -----------------------x----------------------------------------------------
83: o \
84:
85: !include <ntwin32.mak>
86:
87: all: main.exe the_dll.dll
88:
89: main.obj: main.c
90: $(cc) $(cdebug) $(cflags) $(cvars) main.c
91:
92: the_dll.obj: the_dll.c
93: $(cc) $(cdebug) $(cflags) $(cvars) the_dll.c
94:
95: the_dll.rbj: the_dll.rc the_dll.bmp the_dll.cur the_dll.ico
96: rc -r -fo the_dll.res the_dll.rc
97: cvtres -$(CPU) the_dll.res -o the_dll.rbj
98:
99: the_dll.dll: the_dll.def the_dll.rbj the_dll.obj
100: $(link) $(linkdebug) \
101: -base:0x1C000000 \
102: -dll \
103: -entry:DLLEntryPoint$(DLLENTRY) \
104: -out:the_dll.dll \
105: the_dll.rbj the_dll.obj $(guilibs)
106:
107: main.exe: main.obj main.def
108: $(cvtobj) $(cvtdebug) *.obj
109: $(link) $(linkdebug) $(guiflags) -out:main.exe main.obj $(guilibs)
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.