Do not let a program start twice (variables should not be the same as other programs ):
// Create mutex
HANDLE hMutexWF = CreateMutex (NULL, FALSE, "WFBsNavRunOnlyOneInstance ");
If (hMutexWF = NULL | ERROR_ALREADY_EXISTS =: GetLastError () // restrict Double Start
{
If (hMutexWF! = NULL)
{
CloseHandle (hMutexWF );
}
Return false;
}
C ++ builder cannot be stretched:
Set the Form attribute BorderStyle to bsSingle or bsDialog.
Desktop shortcuts:
// Header file
# Include <registry. hpp>
// Use
CreateLnk (Application-> ExeName, "name ");
// Method
//----------------------------------------------------------------------
Void _ fastcall TForm2: CreateLnk (String FilePath, String FileName ){
LPMALLOC ShellMalloc;
LPITEMIDLIST implements toppidl;
Char character topdir [MAX_PATH];
If (FAILED (SHGetMalloc (& ShellMalloc ))){
Return;
}
If (FAILED (SHGetSpecialFolderLocation (NULL, CSIDL_DESKTOPDIRECTORY, & DesktopPidl ))){
Return;
}
If (! SHGetPathFromIDList (using toppidl, using topdir )){
ShellMalloc-> Free (writable toppidl );
ShellMalloc-> Release ();
Return;
}
ShellMalloc-> Free (writable toppidl );
ShellMalloc-> Release ();
IShellLink * pLink;
IPersistFile * pPersistFile;
If (SUCCEEDED (CoInitialize (NULL ))){
If (SUCCEEDED (CoCreateInstance (CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
IID_IShellLink, (void **) & pLink ))){
PLink-> SetPath (FilePath. c_str ());
If (SUCCEEDED (pLink-> QueryInterface (IID_IPersistFile, (void **) & pPersistFile ))){
WideString strShortCutLocation = shorttopdir;
StrShortCutLocation + = "\" + FileName + ". lnk ";
PPersistFile-> Save (strShortCutLocation. c_bstr (), 0 );
PPersistFile-> Release ();
}
PLink-> Release ();
}
CoUninitialize ();
}
}
From an empty column