2014年6月11日 星期三

[Mac OS] How To Capture a Screen Shot with Mac OS X

1. Command+Shift+3
   To capture the entire desktop, and then will be automatically saved as a PNG file on your desktop.

2. Command+Control+Shift+3
   To copy the entire desktop, and then will be placed on your clipboard for you to paste into another program.

3. Command+Shift+4
    To capture a portion of the desktop. A cross-hair cursor will appear and you can click and drag to select the area you wish to capture. When you release the mouse button, the screen shot will be automatically saved as a PNG file on your desktop. (The file is saved as PDF in Mac OS 10.3 and earlier.)

4. Command+Shift+4, then press the Spacebar
   To capture a specific application window. The cursor will change to a camera, and you can move it around the screen. As you move the cursor over an application window, the window will be highlighted. The entire window does not need to be visible for you to capture it. When you have the cursor over a window you want to capture, just click the mouse button and the screen shot will be saved as a PNG file on your desktop. (The file is saved as PDF in Mac OS 10.3 and earlier.)

2014年4月6日 星期日

[Windows] How to lock your computer using command line

Step 1:
Open a DOS promot for launching a special command line. One simple way you can do it would be by clicking Start/Run, typing cmd.

Step 2:
Enter  the command line for locking your station:
rundll32.exe user32.dll, LockWorkStation

2014年3月3日 星期一

[Win32] How to get the app owner version?

Example:

    CString strResult;
    TCHAR szModPath[MAX_PATH];
    ZeroMemory(szModPath, sizeof(TCHAR) * MAX_PATH);
    GetModuleFileName(NULL, szModPath, sizeof(szModPath));
    DWORD dwHandle;

    DWORD dwSize = GetFileVersionInfoSize(szModPath, &dwHandle);
    if (dwSize > 0)
    {
        BYTE* pbBuf = static_cast<BYTE*>(alloca(dwSize));
        if (GetFileVersionInfo(szModPath, dwHandle, dwSize, pbBuf))
        {
            UINT uiSize;
            BYTE* lpb;
            if (VerQueryValue(pbBuf, L"\\VarFileInfo\\Translation", (void**)&lpb, &uiSize))
            {
                WORD* lpw = (WORD*)lpb;
                CString strQuery;
                strQuery.Format(L"\\StringFileInfo\\%04x%04x\\ProductVersion", lpw[0], lpw[1]);
                if (VerQueryValue(pbBuf, const_cast<LPTSTR>((LPCTSTR)strQuery), (void**)&lpb, &uiSize ) && uiSize > 0)
                {
                    strResult = (LPCTSTR)lpb;
                }
            }
        }
    }

[Win32] How to get the OS Version?

DWORD WINAPI GetVersion(void);

Examples:
#include <windows.h>
#include <stdio.h>

void main()
{
    DWORD dwVersion = 0; 
    DWORD dwMajorVersion = 0;
    DWORD dwMinorVersion = 0; 
    DWORD dwBuild = 0;

    dwVersion = GetVersion();
    // Get the Windows version.

    dwMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
    dwMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));

    // Get the build number.

    if (dwVersion < 0x80000000)              
        dwBuild = (DWORD)(HIWORD(dwVersion));

    printf("Version is %d.%d (%d)\n", 
                dwMajorVersion,
                dwMinorVersion,
                dwBuild);
}

Reference:http://msdn.microsoft.com/en-us/library/windows/desktop/ms724439(v=vs.85).aspx

2014年1月7日 星期二

[Java, Windows 8] How to transform Java List to Store apps C++/CX?

Java codes:

private static List<String> vv = new ArrayList<String>();

vv.add("area");
vv.add("base");
vv.add("basefont");
vv.add("br");
vv.add("col");
vv.add("frame");
vv.add("hr");
vv.add("img");
vv.add("input");
vv.add("isindex");
vv.add("link");
vv.add("meta");
vv.add("param");

String ss = "hr";
if (vv.contains(ss))
{
/* vv contains ss */
}
else
{
/* vv does not contain xx */
}

==> Store apps C++/CX
Platform::Collections::Vector<Platform::String^>^ vv = ref new Vector<Platform::String^>();

vv->Append("area");
vv->Append("base");
vv->Append("basefont");
vv->Append("br");
vv->Append("col");
vv->Append("frame");
vv->Append("hr");
vv->Append("img");
vv->Append("input");
vv->Append("isindex");
vv->Append("link");
vv->Append("meta");
vv->Append("param");

unsigned int index = 0;
String^ ss = "hr";
if (vv->IndexOf(ss, &index))
{
/* vv contains ss */
else
{
/* vv does not contain xx */
}