|
den2k88 wrote: I'm writing a C++ class... When I first read that, I thought you were writing a C++ class, and thus the rest of your message made no sense.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Oh thank goodness. Now it all makes sense. I wonder how many others here parsed it the same way.
Keep Calm and Carry On
|
|
|
|
|
Personally you are doing it all backwards you give new graduates the company programming rules and guidelines and tell them what happens if they submit junk that doesn't conform ... which usually involves buying rounds of beers.
They will have a pile of bad habits and completely unacceptable risks they picked up at uni and thought was cool and some are just dam lazy.
Then you get them to try and write a simple program that conforms and discuss the errors and violations they will without doubt submit.
Trust me there will be as many different coding styles as you have graduates and somehow you have to get them all to be able to read each others code as well as you. You aren't trying to stifle thinking and coding imagination but you need to get them on the same pages with standards.
As for examples... Rosetta Code has hundreds
Category:C - Rosetta Code[^]
In vino veritas
modified 2-Apr-20 11:27am.
|
|
|
|
|
They don't know C++ at all, just the basics of C without any practical programming with the exception of the laboratories and exams (of course there are exceptions, one or two each batch of 30).
Most of them rarely used a compiler, coding rules are way bove their head.
GCS d--(d+) s-/++ a C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++* Weapons extension: ma- k++ F+2 X
|
|
|
|
|
den2k88 wrote: Most of them rarely used a compiler More recruits to QA 
|
|
|
|
|
They usually use SO, CP is quite unknown here in Italy except for the actual professionals.
GCS d--(d+) s-/++ a C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++* Weapons extension: ma- k++ F+2 X
|
|
|
|
|
How is TCHAR and char different?
|
|
|
|
|
TCHAR is a macro that is evaluated either as char or unsigned short, depending on the enabling of unicode support.
TCHAR is favored for strings because it reduces the risk of misalignemnts between pieces of code that use char and pieces that use short, also allows for a modicum of configurability (in theory you could enable Unicode strings just enabling Unicode support, in practice it's not that simple).
GCS d--(d+) s-/++ a C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++* Weapons extension: ma- k++ F+2 X
|
|
|
|
|
den2k88 wrote: in practice it's not that simple It can be if you use all the correct macros. I have a number of projects where it works seamlessly.
|
|
|
|
|
It is if you use all the correct macros and good programming practices. Which, on large and/or legacy projects with multiple programmers in space and time, is not necessarily a valid assumption, sadly.
GCS d--(d+) s-/++ a C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++* Weapons extension: ma- k++ F+2 X
|
|
|
|
|
Why does "sadly" sometimes make me smile? 
|
|
|
|
|
I've seen things.
We all have seen things.
GCS d--(d+) s-/++ a C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++* Weapons extension: ma- k++ F+2 X
|
|
|
|
|
The overwhelming use of it is when you want to use unicode but have the code portable for the none unicode situation.
It isn't just TCHAR you use in that situation but you place all string literals inside the _T() or TEXT() macros so they also port and use the TCHAR string functions _tcslen for strlen, _tcscpy_s for strcpy_s etc so all the string functions port.
So being precise about this on Visual Studio with a project open goto the last debug menu which is the project properties then goto
Configuration Properties->Advanced->Character Set you now have 3 options not set (aka use ansi), use unicode and use multi-byte wide character. When you use TCHAR and the above macros and stuff in <tchar.h> you can compile your code in any of those modes and it will work completely seamlessly.
I use it a lot because I write many multilingual windows applications which have large use in non English language areas.
It becomes second nature like using stdint.h and proper sized integers rather than int, short, long etc which are problematic porting.
In vino veritas
modified 2-Apr-20 10:59am.
|
|
|
|
|
That sheeds light on it. Thanks for taking time to write that down and share your knowledge leon.
`DreamLand Page` on facebook
modified 2-Apr-20 12:34pm.
|
|
|
|
|
I noticed today when editing a program on Visual C++ 2015 that if I left a variable undeclared, it showed underlined in red, similar to misspellings in Word for Windows. That is useful. Thanks to whoever put that feature in.
|
|
|
|
|
I think this message is meant for Microsoft.
|
|
|
|
|
|
CodeProject did not write Visual Studio. But I agree, it's a good feature.
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
Hi i am using following code for silent installation of MSI am getting 2203 error.
This is the code i am using.
Not working if i pass domain Administrator username and password, it is giving error like "The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2203".
Can anyone tell me how to resolve this issue.
Note: It is working fine if i pass the local/Built-in administrator username and password.
UAC is enabled in the PC.
strTempFolderToDownload = "msiexec /a "+ MSILocaltion + " ALLUSERS=0" + " TARGETDIR=" + '"' +Installlocation+ '"' + " /qb"
bLogonRet = LogonUser(strUserName, strDomainName, strPassWord, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT , &hToken);
if(bLogonRet && hToken!=NULL)
{
BOOL benvBlock = CreateEnvironmentBlock(&lpvEnv, hToken, TRUE);
if(benvBlock)
{
dwSize = sizeof(szUserProfile)/sizeof(WCHAR);
BOOL bUsrProDir = GetUserProfileDirectory(hToken, szUserProfile, &dwSize);
if(bUsrProDir)
{
bCreateRet = CreateProcessWithLogonW(strUserName, strDomainName, strPassWord, LOGON_WITH_PROFILE, NULL, CT2W(strTempFolderToDownload),CREATE_UNICODE_ENVIRONMENT, lpvEnv, szUserProfile, &si, &pi );
}
}
}
As well as i tried only with following code also no luck.
CreateProcessWithLogonW(strUserName, strDomainName, strPassWord, LOGON_WITH_PROFILE, NULL, CT2W(strTempFolderToDownload),CREATE_UNICODE_ENVIRONMENT, NULL, NULL, &si, &pi );
CreateProcessWithLogonW(strUserName, strDomainName, strPassWord, NULL, NULL, CT2W(strTempFolderToDownload),NULL, NULL, NULL, &si, &pi );
|
|
|
|
|
|
2203 in an administrative install usually means "access denied".
Where are you installing it to and is the account running the MSIEXEC command an administrator? Is the .MSI copied to the local machine before you launch it?
Also, "ALLUSERS=0" isn't really a thing. The behavior of ALLUSERS isn't defined for a value of 0. The behavior is defined for values 1 and 2 and for an empty string ("").
A value of 1 is for a "per-machine" install or "all users", which is typical if you're installing to Program Files.
A value of 2 is for letting MSIEXEC determine which type of installation it should do, checking the value of the MSIINSTALLPERUSER property.
See ALLUSERS property - Win32 apps | Microsoft Docs[^] for more.
|
|
|
|
|
Hi Dave,
Thanks for the posting.
1.) I am trying to install in C:\Program Files(x86)\ folder.
2.) I logged in as non admin user, am trying to install the MSI with domain Administrator credentials am using CreateProcessWithLogonW to do this.
3.) Yes, i copied the installer into temp location.
|
|
|
|
|
OK.
In that case, if the command line your code generated works if an admin on the machine runs it, the problem is going to be in your code that logs in as an admin, but apparently doesn't run anything as an admin. I couldn't tell you what the problem is there.
|
|
|
|
|
Thanks for your help to people who ask queries.
I know how to ask for a file to read from, or a file to write to :-
BOOL GetFileName(HWND wn,char*file,char*titl,char*filter,short write) {short j;
strcpy(file,title);
ofn.lStructSize=sizeof(OPENFILENAME); ofn.hwndOwner=wn;
ofn.lpstrFilter=filter; ofn.lpstrCustomFilter=0;
ofn.lpstrFile=file; ofn.nMaxFile=1024;
ofn.lpstrFileTitle=title; ofn.nMaxFileTitle=1024;
ofn.lpstrInitialDir=0; ofn.lpstrTitle=titl;
ofn.Flags=write?OFN_OVERWRITEPROMPT:OFN_FILEMUSTEXIST;
j=(write?GetSaveFileName(&ofn):GetOpenFileName(&ofn))?1:0;
return j;}
('ofn' and 'title' are declared globally.)
but when I need to ask for a directory / folder, I must do something like this:
K=GetFileName(wn, slidefilename, "name of a file in the directory to read slides from?", slidefiletype, 0);
Is there something like GetOpenFileName, but returning the name of a directory rather than the name of a file?
modified 30-Mar-20 0:49am.
|
|
|
|
|