Click here to Skip to main content
15,885,985 members
Home / Discussions / Windows Development
   

Windows Development

 
PinnedSome links to get started with Metro PinPopular
Nish Nishant23-Feb-12 10:11
sitebuilderNish Nishant23-Feb-12 10:11 
QuestionMultiboot flash drive with Win10 Pin
Jerome Stull25-Mar-24 3:12
Jerome Stull25-Mar-24 3:12 
QuestionWindows APP Cert Kit Error Pin
Gennady4614-Dec-23 22:02
Gennady4614-Dec-23 22:02 
AnswerRe: Windows APP Cert Kit Error Pin
Dave Kreskowiak17-Dec-23 6:18
mveDave Kreskowiak17-Dec-23 6:18 
PraiseRe: Windows APP Cert Kit Error Pin
Gennady4619-Dec-23 21:00
Gennady4619-Dec-23 21:00 
QuestionHow to get Japanese Kanji with phonetic from excel file Pin
a9536004214-Sep-23 0:33
a9536004214-Sep-23 0:33 
AnswerRe: How to get Japanese Kanji with phonetic from excel file Pin
jschell14-Sep-23 11:01
jschell14-Sep-23 11:01 
QuestionWin.iso setup reboot process Pin
Rw23718-Aug-23 4:53
Rw23718-Aug-23 4:53 
QuestionIs anyone actually using Win UI 3 (and if not that, then what?) Pin
Peter Moore - Chicago12-Jun-23 12:58
Peter Moore - Chicago12-Jun-23 12:58 
AnswerRe: Is anyone actually using Win UI 3 (and if not that, then what?) Pin
Texas45195-Aug-23 8:28
Texas45195-Aug-23 8:28 
GeneralRe: Is anyone actually using Win UI 3 (and if not that, then what?) Pin
Gerry Schmitz5-Aug-23 15:38
mveGerry Schmitz5-Aug-23 15:38 
QuestionLoadString with cchBufferMax == 0 Pin
Brian Knittel17-Apr-23 12:03
Brian Knittel17-Apr-23 12:03 
Hi,
The current Microsoft version of the Win32 documentation says that LoadString, LoadStringW, and LoadStringA will pass back a pointer to a read-only copy of a string resource, if the buffer size passed to the routine is 0. In which universe does this happen? This is what I see:
LoadString(hModule, valid_string_id, buf, buflen)       returns length of string
LoadString(hModule, invalid_string_id, buf, buflen)     returns 0
LoadString(hModule, valid_string_id, buf, 0)            returns -1
LoadString(hModule, valid_string_id, NULL, buflen)      throws an exception
LoadString(hModule, valid_string_id, NULL, 0)           throws an exception

I always look at the source code of Wine when I encounter stuff like this, as a first approximation of what might actually be going on internally, and it would appear that Wine would do the same, except for the last case where it would return -1.

I can work around this, no problem. The question is more about the mismatch between the documentation and the behavior. Does anyone have any insight on this?

sample code below. You need to attach a resource file with a valid string defined

#include <windows.h>
#include <stdio.h>
#include "test.h"   // resource include file

#define ARRAYLENGTH(a) (sizeof(a)/sizeof((a)[0]))

int main (int argc, char **argv)
{
    char buf[300];
    int len;
    HMODULE hModule = GetModuleHandle(NULL);

#define TEST_FUNC_CALL(expression) \
    buf[0] = '?';                  \
    buf[1] = 0;                    \
    printf("%s\n", #expression);   \
    __try {                        \
        len = expression;          \
        printf("... returned %d; buf: %s\n\n", len, buf); \
    }                              \
    __except(EXCEPTION_EXECUTE_HANDLER) {   \
        printf("... threw an exception\n\n"); \
    }
   
    TEST_FUNC_CALL(  LoadString(hModule, IDS_STRING1, buf,  ARRAYLENGTH(buf))  ) // valid string ID
    TEST_FUNC_CALL(  LoadString(hModule, 9999,        buf,  ARRAYLENGTH(buf))  ) // invalid ID
    TEST_FUNC_CALL(  LoadString(hModule, IDS_STRING1, buf,  0)                 ) // zero size
    TEST_FUNC_CALL(  LoadString(hModule, IDS_STRING1, NULL, ARRAYLENGTH(buf))  ) // null buffer
    TEST_FUNC_CALL(  LoadString(hModule, IDS_STRING1, NULL, 0)                 ) // both

    return 0;
}

AnswerRe: LoadString with cchBufferMax == 0 Pin
Richard MacCutchan17-Apr-23 22:28
mveRichard MacCutchan17-Apr-23 22:28 
AnswerRe: LoadString with cchBufferMax == 0 Pin
jschell18-Apr-23 5:14
jschell18-Apr-23 5:14 
AnswerRe: LoadString with cchBufferMax == 0 Pin
Brian Knittel18-Apr-23 7:35
Brian Knittel18-Apr-23 7:35 
SuggestionAdding Visual Studio to diskussions? Pin
Bo Vistisen20-Feb-23 12:34
Bo Vistisen20-Feb-23 12:34 
GeneralRe: Adding Visual Studio to diskussions? Pin
Richard MacCutchan20-Feb-23 21:12
mveRichard MacCutchan20-Feb-23 21:12 
QuestionLooking for feedback on why a share on a VPN would auto-lock when using FILE>>OPEN Pin
YSLGuru14-Feb-23 6:42
YSLGuru14-Feb-23 6:42 
AnswerRe: Looking for feedback on why a share on a VPN would auto-lock when using FILE>>OPEN Pin
Dave Kreskowiak18-Feb-23 14:40
mveDave Kreskowiak18-Feb-23 14:40 
GeneralRe: Looking for feedback on why a share on a VPN would auto-lock when using FILE>>OPEN Pin
YSLGuru19-Feb-23 5:51
YSLGuru19-Feb-23 5:51 
AnswerRe: Looking for feedback on why a share on a VPN would auto-lock when using FILE>>OPEN Pin
Gerry Schmitz19-Feb-23 5:21
mveGerry Schmitz19-Feb-23 5:21 
GeneralRe: Looking for feedback on why a share on a VPN would auto-lock when using FILE>>OPEN Pin
YSLGuru19-Feb-23 5:50
YSLGuru19-Feb-23 5:50 
GeneralRe: Looking for feedback on why a share on a VPN would auto-lock when using FILE>>OPEN Pin
Dave Kreskowiak19-Feb-23 5:55
mveDave Kreskowiak19-Feb-23 5:55 
GeneralRe: Looking for feedback on why a share on a VPN would auto-lock when using FILE>>OPEN Pin
YSLGuru19-Feb-23 6:01
YSLGuru19-Feb-23 6:01 
GeneralRe: Looking for feedback on why a share on a VPN would auto-lock when using FILE>>OPEN Pin
Dave Kreskowiak19-Feb-23 5:53
mveDave Kreskowiak19-Feb-23 5:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.