Changeset 83 for trunk/src/user32
- Timestamp:
- Jun 9, 1999, 10:16:53 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/RESSTRING.C
r46 r83 23 23 #include "unicode.h" 24 24 25 static char *UnicodeToAsciiN(WCHAR *wstring, char *astring, int maxlen);26 27 25 /******************************************************************************/ 28 //Strings stored as original: WORD len 26 //Strings stored as original: WORD len 29 27 // UNICODE string (not null terminated) 30 28 /******************************************************************************/ 31 int OS2LoadStringAscii(HINSTANCE hinst, UINT wID, LPSTR lpBuffer, int cchBuffer) 29 int OS2LoadStringAscii(HINSTANCE hinst, 30 UINT wID, 31 LPSTR lpBuffer, 32 int cchBuffer) 32 33 { 33 APIRET rc;34 WCHAR *szbuf;35 char modname[128];36 HMODULE hmodule;34 APIRET rc; 35 WCHAR *szbuf; 36 char modname[128]; 37 HMODULE hmodule; 37 38 38 if(hinst != 0 && hinst != -1) { 39 if(Win32QueryModuleName(hinst, modname, sizeof(modname)) == 0) { 40 #ifdef DEBUG 41 WriteLog("Can't determine handle of dll %X\n", hinst); 42 #endif 43 return(0); 44 } 45 rc = DosQueryModuleHandle(modname, &hmodule); 46 if(rc) { 47 #ifdef DEBUG 48 WriteLog("Can't determine handle of dll %s\n", modname); 49 #endif 50 return(0); 51 } 39 if(hinst != 0 && hinst != -1) 40 { 41 if(Win32QueryModuleName(hinst, 42 modname, 43 sizeof(modname)) == 0) 44 { 45 dprintf(("USER32: OS2LoadStringAscii: Can't determine handle of dll %08xh\n", 46 hinst)); 47 return(0); 48 } 49 50 rc = DosQueryModuleHandle(modname, 51 &hmodule); 52 if(rc) 53 { 54 dprintf(("USER32: OS2LoadStringAscii: Can't determine handle of dll %s\n", 55 modname)); 56 57 return(0); 58 } 52 59 } 53 else hmodule = 0; 60 else 61 hmodule = 0; 54 62 55 rc = DosGetResource(hmodule, RT_RCDATA, wID, (PPVOID)&szbuf); 56 if(rc) { 57 #ifdef DEBUG 58 WriteLog("OS2LoadString failed with rc %d\n", rc); 59 #endif 60 if(lpBuffer) *lpBuffer = 0; 61 return(0); //TODO: SetLastError! 63 rc = DosGetResource(hmodule, 64 RT_RCDATA, 65 wID, 66 (PPVOID)&szbuf); 67 if(rc) 68 { 69 dprintf(("USER32: OS2LoadStringAscii failed with rc %08xh\n", 70 rc)); 71 72 if(lpBuffer) 73 *lpBuffer = 0; 74 75 return(0); //TODO: SetLastError! 62 76 } 63 UnicodeToAsciiN(szbuf+1, lpBuffer, min((*szbuf), cchBuffer-1)); 64 #ifdef DEBUG 65 WriteLog("OS2LoadString retrieved string '%s' (size %d)\n", lpBuffer, (int)*szbuf); 66 #endif 77 78 UnicodeToAsciiN(szbuf+1, 79 lpBuffer, 80 min((*szbuf), cchBuffer-1)); 81 82 dprintf(("USER32: OS2LoadStringA retrieved string '%s' (size %d)\n", 83 lpBuffer, 84 (int)*szbuf)); 85 67 86 DosFreeResource(szbuf); 68 return(strlen(lpBuffer)); 87 return(strlen(lpBuffer)); //not including null terminator! 69 88 } 70 89 //****************************************************************************** 71 90 //****************************************************************************** 72 int OS2LoadStringUnicode(HINSTANCE hinst, UINT wID, WCHAR *lpBuffer, int cchBuffer) 91 int OS2LoadStringUnicode(HINSTANCE hinst, 92 UINT wID, 93 WCHAR *lpBuffer, 94 int cchBuffer) 73 95 { 74 APIRET rc; 75 WCHAR *szbuf; 76 char modname[128]; 77 HMODULE hmodule; 96 APIRET rc; 97 WCHAR *szbuf; 98 char modname[128]; 99 HMODULE hmodule; 100 78 101 #ifdef DEBUG 79 102 char *astring; 80 103 #endif 81 104 82 if(hinst != 0 && hinst != -1) { 83 if(Win32QueryModuleName(hinst, modname, sizeof(modname)) == 0) { 84 #ifdef DEBUG 85 WriteLog("Can't determine handle of dll %X\n", hinst); 86 #endif 87 return(0); 88 } 89 rc = DosQueryModuleHandle(modname, &hmodule); 90 if(rc) { 91 #ifdef DEBUG 92 WriteLog("Can't determine handle of dll %s\n", modname); 93 #endif 94 return(0); 95 } 105 if(hinst != 0 && hinst != -1) 106 { 107 if(Win32QueryModuleName(hinst, 108 modname, 109 sizeof(modname)) == 0) 110 { 111 dprintf(("USER32: OS2LoadStringUnicode: Can't determine handle of dll %08xh\n", 112 hinst)); 113 return(0); 114 } 115 116 rc = DosQueryModuleHandle(modname, 117 &hmodule); 118 if(rc) 119 { 120 dprintf(("USER32: OS2LoadStringUnicode: Can't determine handle of dll %s\n", 121 modname)); 122 123 return(0); 124 } 96 125 } 97 else hmodule = 0; 126 else 127 hmodule = 0; 98 128 99 rc = DosGetResource(hmodule, RT_RCDATA, wID, (PPVOID)&szbuf); 100 if(rc) { 101 #ifdef DEBUG 102 WriteLog("OS2LoadString failed with rc %d\n", rc); 103 #endif 104 if(lpBuffer) *lpBuffer = 0; 105 return(0); //TODO: SetLastError! 129 rc = DosGetResource(hmodule, 130 RT_RCDATA, 131 wID, 132 (PPVOID)&szbuf); 133 if(rc) 134 { 135 dprintf(("USER32: OS2LoadStringUnicode failed with rc %08xh\n", 136 rc)); 137 138 if(lpBuffer) 139 *lpBuffer = 0; 140 141 return(0); //TODO: SetLastError! 106 142 } 107 memcpy(lpBuffer, szbuf+1, min((*szbuf), cchBuffer-1)*sizeof(WCHAR)); 143 144 145 memcpy(lpBuffer, 146 szbuf+1, 147 min((*szbuf), cchBuffer-1) * sizeof(WCHAR)); 148 108 149 lpBuffer[min((*szbuf), cchBuffer-1)] = 0; 109 150 110 151 #ifdef DEBUG 111 152 astring = UnicodeToAsciiString(lpBuffer); 112 WriteLog("OS2LoadStringW retrieved string '%s' of size %d\n", astring, (int)*szbuf); 153 WriteLog("USER32: OS2LoadStringUnicode retrieved string '%s' of size %d\n", 154 astring, 155 (int)*szbuf); 113 156 FreeAsciiString(astring); 114 157 #endif 158 115 159 DosFreeResource(szbuf); 116 return(UniStrlen(lpBuffer)); 160 return(UniStrlen(lpBuffer)); //not including null terminator! 117 161 } 118 //******************************************************************************119 //******************************************************************************120 static char *UnicodeToAsciiN(WCHAR *wstring, char *astring, int maxlen)121 {122 int i;123 162 124 for(i=0;i<maxlen;i++) {125 astring[i] = (UCHAR)wstring[i];126 }127 astring[maxlen] = 0;128 return(astring);129 }130 /******************************************************************************/131 /******************************************************************************/132
Note:
See TracChangeset
for help on using the changeset viewer.