= = = Header file before and after order influence TCHAR definition ===============================
Windows.h winnt.h
Tchar.h
====== define _unicode macro constant control ==================
Character
typedef char TCHAR;
typedef wchar_t TCHAR;
String
typedef __t (x) l# #x
typedef __t (x) x
C Library functions
#define _tcslen strlen
#define _tcslen Wcslen
#define _tmain Main
#define _tmain WMAin
#define _tWinMain WinMain
#define _tWinMain wWinMain
===== defining Unicode Constant control =========================
Character
typedef CHAR TCHAR
typedef WCHAR TCHAR
String
#define __TEXT (x) l# #x
#define __TEXT (x) x
typedef LPSTR PTSTR, LPTSTR;
typedef LPWSTR PTSTR, LPTSTR;
System functions
#define MESSAGEBOX MessageBoxA
#define MESSAGEBOX MessageBoxW
===== defined in Tchar.h ======================
TCHAR
__t (x)
#define _T (x) __t (x)
#define _TEXT (x) __t (x)
C Library functions
_tcslen
_tmain
_tWinMain
====== defined in WinNT.h ======================
Character
TCHAR
typedef char CHAR;
typedef wchar_t WCHAR;
String
__text (x)
#define TEXT (x) __text (x)
PTSTR, LPTSTR
Add:
mainCRTStartup ()/wmaincrtstartup () is located in the C Runtime library, which executes first and then calls Main ()/wmain ();
Main entrance
int _tmain (void);
int _tmain (int argc, TCHAR **argv);
int _tmain (int argc, TCHAR *argv[]);
When the entry point is WinMain, the execution begins at WinMainCRTStartup, the same wwainmain, which begins at wWinMainCRTStartup
WinMain Entrance
int WINAPI wWinMain (hinstance hinstance, hinstance hprevinstance, pwstr pcmdline, int ncmdshow);
int WINAPI WinMain (hinstance hinstance, hinstance hprevinstance, LPSTR lpcmdline, int ncmdshow);
int Apientry _tWinMain (hinstance hinstance, hinstance hprevinstance, LPTSTR lpcmdline, int ncmdshow);
Window API String function
String length
int WINAPI Lstrlena (LPCSTR lpstring);
int WINAPI lstrlenw (lpcwstr lpstring);
Stitching strings
LPWSTR WINAPI LSTRCATW (lpwstr lpString1, lpcwstr lpString2);
String Case Conversion
LPWSTR WINAPI charlowerw (LPWStr lpsz);
LPWSTR WINAPI charupperw (LPWStr lpsz);
MultiByteToWideChar WideCharToMultiByte
BOOL Stringreversea (PSTR pmultibytestr)
{
Pwstr Pwidecharstr;
int nlenofwidecharstr;
BOOL fOk = FALSE;
Nlenofwidecharstr = Multirytetowidechar (CP_ACP, 0,pmultibytestr,-1, NULL, 0);
Pwidecharstr = HeapAlloc (GetProcessHeap (), 0, Nlenofwidecharstr * sizeof (WCHAR));
MultiByteToWideChar (CP_ACP, 0, Pmulti8ytestr,-1, Pwidecharstr, NLENOFWIDECHARSTR);
FOk = Stnngreversew (PWIDECHARSTR);
if (fOk)
{
Convert the Wide-character string back
to a multibyte string.
WideCharToMultiByte (CP_ACP, 0, Pwidecharstr,-1,
Pmultibytestr, strlen (PMULTIBYTESTR), NULL, NULL);
}
HeapFree (GetProcessHeap (), 0, PWIDECHARSTR);
Return (FOK),
}
FormatMessage
Get the error code
DWORD dwerror = Getdlgitemint (hwnd, Idc_errorcode, NULL, FALSE);
Buffer that gets the error message string
Hlocal hlocal = NULL;
Get the error code ' s textual description
BOOL fOk = FormatMessage (
Format_message_from_system | Format_message_allocate_buffer,
NULL, Dwerror, Makelangid (Lang_english, Sublang_english_us),
(PTSTR) &hlocal, 0, NULL);
if (hlocal! = NULL)
{
Setdlgitemtext (hwnd, Idc_errortext, (PCTSTR) LocalLock (hlocal));
LocalFree (hlocal);
}
Else
Setdlgitemtext (hwnd, Idc_errortext,
TEXT ("Error number not found."));
Ptstr GetCommandLine ();
Hmodule GetModuleHandle (Pctstr pszmodule);
BOOL CreateProcess (
Pctstr Pszapplicationname,
Ptstr pszCommandLine,
Psecurity_attributes psaprocess,
Psecurity_attributes Psathread,
BOOL bInheritHandles,
DWORD Fdwcreate,
PVOID Pvenvironment,
Pctstr Pszcurdir,
Pstartupinfo Psistartinfo,
Pprocess_information ppiprocinfo);
VOID Getstartupinfo (Lpstartupinfo pstartupinfo);
Osversioninfoex OS = {0};
os.dwosversioninfosize = sizeof (OS);
GetVersionEx ((LPOSVERSIONINFOA) &os);
printf ("%u-%u-%u-%u-%s-%hu-%hu-%hu-%d \ n",
Os.dwmajorversion,os.dwminorversion,os.dwbuildnumber,
Os.dwplatformid,os.szcsdversion,
Os.wservicepackmajor,os.wservicepackminor,os.wsuitemask,
Os.wproducttype);
DWORD WINAPI ThreadFunc (PVOID pvparam)
{
DWORD dwresult = 0;
...
return (dwresult);
}
HANDLE CreateThread (
Psecurity_attributes PSA,
DWORD Cbstack,
Pthread_start_routine Pfnstartaddr,
PVOID Pvparam,
DWORD Fdwcreate,
Pdword Pdwthreadid);
_beginthreadex
DWORD GetCurrentProcessId ();
DWORD GetCurrentThreadID ();
HANDLE getcurrentprocess ();
HANDLE GetCurrentThread ();
Getprocesstimes
Getthreadtimes
__int64 Filetimetoquadword (Pfiletime pft)
{
Return (INT64SHLLMOD32 (
Pft->dwhighdatetime, 32) | Pft->dwlowdatetime);
}
Getthreadtimes
U_long ARGP = 1L;
int nret = ioctlsocket (S, Fionbio, (U_long far*) &ARGP); Non-blocking mode
if (nret = = socket_error)
return;
#include <windows.h>
#include <tchar.h>
int _tmain (int argc, TCHAR *argv[])
{
Pdword cchars = NULL;
HANDLE std = getstdhandle (std_output_handle);
if (std = = invalid_handle_value) {
_tprintf (L "cannot retrieve standard output handle\n (%d)",
GetLastError ());
}
Writeconsole (STD, argv[1], _tcslen (argv[1]), Cchars, NULL);
return exit_success;
}
Windows Unicode-related