Search This Blog

Friday, August 21, 2009

Get the User App Data Directory



#include <shlobj.h>

char path[_MAX_PATH];

//Get the User App Data Directory
SHGetFolderPath(NULL,CSIDL_LOCAL_APPDATA,NULL,0,path);

//Get the Common App Data Directory
SHGetFolderPath(NULL,CSIDL_COMMON_APPDATA,NULL,0,path);

Tuesday, August 11, 2009

To Close SDI/MDI Application Programmatically

AfxGetMainWnd()->PostMessage(WM_CLOSE);

To lock your machine programmatically

To lock your machine programmatically you can use the API LockWorkStation().

Syntax
C++

BOOL WINAPI LockWorkStation(void);


//Code:
if( !LockWorkStation())
{
// Failed to lock the machine
}

This function has the same result as pressing Ctrl+Alt+Del and clicking Lock Workstation. To unlock the workstation, the user must log in. There is no function you can call to determine whether the workstation is locked.