Just mentioning it. I would have said 1000 microseconds in the first place because the possibilities otherwise are endless.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
That's the error. What gave you that expectation, and why burn time/money on it?
Gisle Vanem wrote:
What / where is this 2 sec. set?
Google around and posts point to the registry; but that's not it and will not work. It's not part of the .NET environment, but the network. It's not a regular "setting" of sorts, and 0s on a non-realtime OS is nonsense.
Even on a realtime OS, I'd expect a similar delay to ensure you do not receive packets that were intended for the (now) closed connection.
--edit; I forgot to mention, select is not broken.
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
The usual dumb question from me... and I apologize for being this way. But I see as a trend here in CP project Articles' posters' run up to publishing ... tag lack, beyond the general Visual Studio. It's easy to browse the code; yes. Read the Format version, the actual VS "#" and then there's the "VisualStudioVersion".
I suppose I want to head off the "This project created with a newer version of Visual Studio" warning. But that "MinimumVisualStudioVersion" has always had me baffled as when I open a newer project that, if the "minimum" were indeed something to Visual Studio, my VS, which passes muster according to this spec, never seems to be able to do much in the way of filling out the Browser tree beyond the next message "fail to load project" (sp).
Short of suggesting I subscribe to the latest VS incarnation, are there any acceptable apologies for for this descriptive non sense from MS then?
Why has Binding never caught on in Windows Forms. I have been using binding in Wpf for years. Have not paid much attention to Windows Forms. Someone just pointed out that Windows Forms has binding. Looking it up they have had it since .Net2. Occasionally I have had to maintain a Windows Forms app and have never seen it used.
So many years of programming I have forgotten more languages than I know.
If one never leaves the Designer, and believes all the "no code behind", then one never learns about Windows Forms binding, etc. It's when you start writing your own framework(s) and patterns that all this starts to come to the surface. For some, that is a bad thing ("details").
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
That will require creating another table to handle the numbering for your application plus coding to handle the incremented value in that column, well, simply, I don't bind the PK, I handle it manually.
I've come to realize there's no point in binding the autonumber/PK because, at most, it's only used for display. It's not something the user can edit. I display it in a label, using "New" when it's -1.
I've been working with this batch file for a few hours and I can't seem to getthis file to work properly and I can't use PowerShell because my company's network won't allow it so I'm using a batch file. I'm trying to go through a list of machines and I can't seem to get past the first machine. I think I found the issue though but can't seem to get the line fixed to go to the second machine. I think it's after the findstr line after troubleshooting the code line by line.
Here's my code of what I tried.
For /f %%i in (C:\Users\%username%\desktop\computers.txt) do (
echo %DATE% %TIME%
ping %%i /n 1 | find "Reply from %%i:"
if errorlevel 0 echo The computer is online and on VPN
if errorlevel 1 echo The computer is offline or not on VPN
if errorlevel 1 goto skip
REG QUERY "\\%%i\regpath" | findstr "Computer"
query user /server:%%i
dir /T:W "\\%%i\C$\path\file.exe" | find "exe"
(findstr /i /l "configurationserver=https://URL" \\%%i\C$\path\file.ini > NUL && (goto skip) || goto fixfile)
echo pfile.ini isn't good
code to fix issue
echo file is good
""for testing purposes the computers.txt has two computer IP Addresses
I've tried errorlevel for the findstr and also the second solution within the code.
It's impossible to test your script, but I will say if FINDSTR finds the string in the file, ERRORLEVEL will be 0. If not found, or the file does not exist, ERRORLEVEL will be 1.
When you check for ERRORLEVEL in a block of IF statements, you have to check for the highest possible errorlevel value first and check for 0 last. This is because the IF ERRORLEVEL will return true if ERRORLEVEL is greater than or equal to the specified value. So if you check for 0 first, the result will always be true, no matter what the value of ERRORLEVEL is.
Remove the ECHO's from your IF statements and just jump to a block that contains the ECHO statements and what to do after that. This will eliminate the need for multiple IF statements checking for the same ERRORLEVEL.
I have a requirement to display a shutdown message (using the InitiateSystemShutdownExW API) from a service, but using the interactive user's language.
The GetUserDefaultLCID looks like it should do what I want, but it doesn't. I assume that is because my service is not running in the interactive user's context. It instead returns the "install language" for the system.
Is there a way to programmatically retrieve the interactive user's language (e.g. using the remote session API)?
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
I think you are asking if it's possible to use the GetUserDefaultLCID function by impersonating the security context of a logged-on user. But I'm not sure if you know what that means. For example User1 (or Administrator) can execute apps as User2 and User3 which means all those user accounts will have 'interactive sessions'.
Also... you need to clarify which user language[^] you want to use. For example, some users might have MUI enabled[^] and have both Hebrew and English (or maybe a dozen).
If you really do want to look up the same information that the GetUserDefaultLCID function retrieves for a user that logged in via winlogon.exe from your system service then I can help you do that.
#pragma comment(lib, "Secur32.lib")
#pragma comment(lib, "Advapi32.lib")
BOOL RegGetInternationaliations(const PSID p, constwchar_t name, wchar_t *pOut, DWORD out_len)
LPWSTR szSid = nullptr;
BOOL bRet = FALSE;
if (ConvertSidToStringSidW(p, &szSid))
constexpr DWORD size = 256;
wsprintf(buffer, L"%s\\Control Panel\\International", szSid);
LSTATUS status = RegOpenKeyW(HKEY_USERS, buffer, &k);
if (ERROR_SUCCESS == status)
status = RegGetValueW(k, NULL, name, RRF_RT_REG_SZ | RRF_ZEROONFAILURE, 0, pOut, &out_len);
bRet = (ERROR_SUCCESS == status);
DWORD lc = 0;
DWORD status = 0;
PLUID list = nullptr;
for (DWORD i = 0; i < lc; i++)
status = LsaGetLogonSessionData((PLUID)((INT_PTR)list + sizeof(LUID) * i), &pData);
if (0 == status)
if (Interactive == pData->LogonType && (pData->UserFlags & LOGON_WINLOGON))
constexpr DWORD s = 256;
if (RegGetInternationaliations(pData->Sid, L"Locale", buffer, s))
wprintf(L"Locale: %s\n", buffer);
This will work from session 0 and does exactly the same thing as the GetUserDefaultLCID function for the logged in users. Those internationalization registry keys have been pretty much unchanged for 14 years (I think the last change there was 2006)
If you really do want to do this for ALL interactive sessions then remove the following:
if (Interactive == pData->LogonType && (pData->UserFlags & LOGON_WINLOGON))
Also... if this isn't what you wanted... and what you really wanted was the currently selected MUI language[^] then let me know, it's an easy change.
I'm getting off now so I won't be back until tomorrow to read your response.
UINT index = 1;
for (auto lang : langs)
wprintf(L"User Preferred UI Language at index %u is: %s \n", index++, lang.c_str());
My understanding is that the first entry is the current preferred UI language.
I have some additional comments:
1.) If you are doing this in a corporate environment then you might want to check for the domain/machine policy[^] first. The security policy is located in the registry at HKLM\Software\Policies\Microsoft\MUI\Settings and you would need to honor that.
2.) You will need to use a multi-tiered fallback. The HKCU\Control Panel\Desktop\PreferredUILanguages key will not exist if the user has not setup MUI and a default language. I believe you need fallback in this order:
* HKCU\Control Panel\Desktop\PreferredUILanguages (User prference) **might not be present**
* HKCU\Control Panel\Control Panel\International\Locale (User default) **always present**
* HKLM\SYSTEM\CurrentControlSet\Control\MUI\Settings\PreferredUILanguages (MUI default) **might not be present**
* HKLM\SYSTEM\CurrentControlSet\Control\Nls\Language\Default **always present**
* HKLM\SYSTEM\CurrentControlSet\Control\Nls\Language\InstallLanguage **always present**
I apologize for the slow response. I haven't been on codeproject.com in a few weeks.
All of the sample code that I have written here in this forum is now in the public domain. You may use, modify and share it without restriction. Attribution is unnecessary. Keep in mind that it is a code sample and there is no guarantee of completeness or accuracy.
It looks like I am going to be mostly unavailable for the next few weeks. So I might not have much time for internet forums.. I should have more time in November.
Looking at the above code do see a potential political issue for your geo region. Make sure that you understand what "neutral names" implies with the LOCALE_ALLOW_NEUTRAL_NAMES flag. Or just remove it.
I also see a potential divide-by-zero surrounding the DWORD dwNeeded where the length comes from the registry, might want to add a if(dwNeeded) around that. It's an imperfect code sample, so you might want to polish it up a bit.
Last Visit: 31-Dec-99 18:00 Last Update: 2-Oct-22 16:41