FAQ Questions

1. What are the differences between Win32 and MFC?
2. How do I run the window in full screen mode?
3. How do I read/write in the Windows registry?
4. How do I run an .exe file?
5. What is #define WIN32_LEAN_AND_MEAN for?
6. Is it possible to make MS-DOS run shorcuts?

FAQ Answers

Q: What are the differences between Win32 and MFC?
A: MFC means “Microsoft Foundation Classes”. It is written in Win32. Win32 is a set of functions for Windows operating systems.
In fact, it’s not that easy, to be explained in two sentences, but if you want to know details and such, just visit our tutorials section, and browse the appropriate tutorials.

Q: How do I run the window in full screen mode?
A: The easiest way is:

keybd_event(VK_MENU,0x38,0,0);
keybd_event(VK_RETURN,0x1c,0,0);
keybd_event(VK_RETURN,0x1c,KEYEVENTF_KEYUP,0);
keybd_event(VK_MENU,0x38,KEYEVENTF_KEYUP,0);

Don’t forget to include windows.h

Q: How do I read/write in the Windows registry?
A:

HKEY root;
TCHAR szData[80];
DWORD dwBufSize = 80, dwType;
const TCHAR szRegRoot[] = _T(”Software\\WhatEverYouWish”);

RegOpenKeyEx(HKEY_LOCAL_MACHINE, szRegRoot, 0, KEY_READ, &root);

Read value:

RegQueryValueEx(root, "blabla", NULL, &dwType, (BYTE *)szData, &dwBufSize);

Write value to registry:

RegSetValueEx(root, "blabla", 0, REG_SZ, (const BYTE*)&szData, dwBufSize);

Q: How do I run an .exe file?
A: This way:

ShellExecute(NULL,"open","NOTEPAD.EXE",NULL,NULL,SW_SHOWNORMAL);

And don’t forget to include the windows.h header file.
Also, have in mind that when you invoke a file from some location, you should type \\ instead of \. For example:

C:\\Windows\\NOTEPAD.EXE

Another way is:

spawnl(P_WAIT, "myprog.exe", "myprog.exe", NULL); //include process.h

There are two more API functions that can run a program:
WinExec it is not recommended because it is out of date.
CreateProcess it is more complex function to use, although it provides more flexibility.

Q: What is #define WIN32_LEAN_AND_MEAN for?
A: It is often mistaken that WIN32_LEAN_AND_MEAN excludes all MFC stuff. In fact, it has nothing to do with the MFC stuff.
It works with the Win32 API which is what MFC wraps. MFC is a higher level method of working with the Win32 API; the Win32 API knows nothing of MFC.
WIN32_LEAN_AND_MEAN excludes windows headers that are normally not used (such as shellapi.h).

by Invader X

Q: Is it possible to make MS-DOS run shorcuts?
A: Yes, if you just have a command prompt open from Windows.
Just use the ’start’ program like so:

c:\windows\desktop\somelink.lnk

You can use the ShellExecute function to start the program.

Tags: ,

Leave a Reply

You must be logged in to post a comment.