C++ & SDK
I'm completely new at C++, though have reasonable experience with .NET.
I'm trying to switch from VB.net to C++ because I want to write native code... but i'm having problems.
I have 'Microsoft Platform SDK for Windows XP SP2' and 'Visual C++ 2005 Express Edition Beta 2' installed. I have also created a dir in "C:\Program Files\Microsoft Visual Studio 8\VC" called 'PlatformSDK' which has the Bin, Include and Lib folders in it.
Now how do i make a native program, not complied in .NET?
If i go to File|New|Project| Win32.... I can only select console application, windows application is greyed out.
If i select "Windows form application" it compiles in .NET..
Do i need to register the PSDK directorys? or set up some paths?
Please help!
[785 byte] By [
C.T] at [2008-3-6]
Hi C.T!
I have 'Microsoft Platform SDK for Windows XP SP2' and 'Visual C++ 2005 Express Edition Beta 2' installed. I have also created a dir in "C:\Program Files\Microsoft Visual Studio 8\VC" called 'PlatformSDK' which has the Bin, Include and Lib folders in it.
This is the "wrong" SDK... with this you can only develop apps for XP-SP2!
You should download the newest (uniformed) PSDK:
http://www.microsoft.com/downloads/details.aspx?FamilyId=D8EECD75-1FC4-49E5-BC66-9DA2B03D9B92 Now how do i make a native program, not complied in .NET?If i go to File|New|Project| Win32.... I can only select console application, windows application is greyed out.
Create a "console-app" and the go to the linker settings (Project|Properties|Linker|General) and select "Subsystem: Windows".
Do i need to regester the PSDK directorys? or set up some paths?
No, it is already registred by default.
Greetings
Jochen
PS: Please mark the best replies as anserws!
Which version do you mean?
PSDK XP-SP2: Designed only for XP-SP2 development!
PSDK W2003SP1: Designed to be used for *all* Windows OSs.
Greetings
Jochen
Ok.. downloaded and set up that.. Followed the linker steps.. now i get:
Linking...
MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function _WinMainCRTStartup
Debug\test.exe : fatal error LNK1120: 1 unresolved externals
C.T at 2007-8-21 >

I've installed the PSDK W2003SP1 but I can't compile the following simple code:
#include <windows.h>
int
APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow){ MessageBox(NULL,
"Ciao","MsgBox",0);
return 0; }
The build log file is:
| | | Build started: Project: prova, Configuration: Debug|Win32 |
| | | Creating temporary file "c:\Documents and Settings\Paolo\Desktop\Prove C++\Prova\prova\prova\Debug\RSP00001B28041536.rsp" with contents [ /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /Gm /EHsc /RTC1 /MDd /GS- /Fo"Debug\\" /Fd"Debug\vc80.pdb" /W3 /c /Wp64 /ZI /TP ".\main.cpp" ] Creating command line "cl.exe @"c:\Documents and Settings\Paolo\Desktop\Prove C++\Prova\prova\prova\Debug\RSP00001B28041536.rsp" /nologo /errorReport rompt" |
| | | Compiling... main.cpp c:\documents and settings\paolo\desktop\prove c++\prova\prova\prova\main.cpp(4) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char ' to 'LPCWSTR' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast |
| | | Build log was saved at "file://c:\Documents and Settings\Paolo\Desktop\Prove C++\Prova\prova\prova\Debug\BuildLog.htm" prova - 1 error(s), 0 warning(s) |
In VC++ 6.0 the same code work great!!
What's wrong?
Thanks Paolo
P.S. My OS is MS Windows XP Home SP2
By default the project setting is UNICODE!
Therefor you should use the T-Macros!!! (TCHAR ...)
http://msdn.microsoft.com/library/en-us/vccore/html/_core_generic.2d.text_mappings_in_tchar..h.asp
Your example should look like:
#include <windows.h>
#pragma comment(lib, "user32.lib")
#include <tchar.h>
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
MessageBox(NULL, _T("Ciao"), _T("MsgBox") , MB_OK);
return 0;
}
Or you can switch to ANSI (or Mutli-Byte-Character set): Project|Settings|General: Character encoding