Welcome

Wheresoever you go, go with all your heart. (Confucius)

10/11/2011

Restoring Grub2 from the booting cd-rom

In case of Debian Squeeze,
after going into the install steps, proceed until loading the device drivers.
Then, if pushed Ctrl+Alt+F2, you can get the command prompt.

# fdisk -l
# mount -t ext4 /dev/XXX /chroot
# mount --bind /dev /chroot/dev
# mount -t sysfs none /chroot/sys
# mount -t proc none /chroot/proc
# chroot /chroot/
# grub-install /dev/XXX

Single instance in MFC

Sometimes you want to make your application only with a single instance.
Unfortunately MFC don't provide any APIs. However, there is the simplest method by MUTEX.

First, you create the globally unique identifier (GUID) to create MUTEX.
MFC provides creating GUID: Tools-Create GUID.
after creating it, just copy and paste in your code.

The following code located in InitInstance() of MFC.

CString stringGUID = L"........";
HANDLE hMutex = CreateMutex(NULL, TRUE, stringGUID);
if( GetLastError() == ERROR_ALREADY_EXISTS )
{
    CloseHandle(hMutex);
    return FALSE;
}