smartphone 下读取快捷方式 (2)

使用系统的api读取快捷方式是没有问题的SHGetShortcutTarget,下面给了,自己写得读取的例子,虽然自己写的很辛苦,但最后还是使用的系统的~~

 1 smartphone 下读取快捷方式 (2) TCHAR *  CMainDlg::GetShortCut(LPCTSTR strFileName)
 2 smartphone 下读取快捷方式 (2) {
 3smartphone 下读取快捷方式 (2)    HANDLE hFile = CreateFile(strFileName,GENERIC_READ,FILE_SHARE_READ,
 4smartphone 下读取快捷方式 (2)        NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
 5smartphone 下读取快捷方式 (2)    if(hFile != INVALID_HANDLE_VALUE)
 6smartphone 下读取快捷方式 (2)    {
 7smartphone 下读取快捷方式 (2)        char szBuffer[255];            // buffer for receives data
 8smartphone 下读取快捷方式 (2)        DWORD dwNumOfBytesRead;                // pointer to number of bytes read
 9smartphone 下读取快捷方式 (2)        ZeroMemory(szBuffer, sizeof(szBuffer));
10smartphone 下读取快捷方式 (2)        if(ReadFile(hFile,szBuffer,255&dwNumOfBytesRead, NULL))
11smartphone 下读取快捷方式 (2)        {
12smartphone 下读取快捷方式 (2)            CloseHandle(hFile);    
13smartphone 下读取快捷方式 (2)            if(dwNumOfBytesRead != 0)
14smartphone 下读取快捷方式 (2)            {                        
15smartphone 下读取快捷方式 (2)                char* pLastChar = strchr(szBuffer,'#');
16smartphone 下读取快捷方式 (2)                pLastChar++;
17smartphone 下读取快捷方式 (2)                int widecharlen=MultiByteToWideChar(  //计算从Ansi转换到Unicode后需要的字节数
18smartphone 下读取快捷方式 (2)                    CP_ACP,MB_COMPOSITE,pLastChar,  //要转换的Ansi字符串
19smartphone 下读取快捷方式 (2)                    -1,  //自动计算长度
20smartphone 下读取快捷方式 (2)                    0,
21smartphone 下读取快捷方式 (2)                    0
22smartphone 下读取快捷方式 (2)                    );
23smartphone 下读取快捷方式 (2)                wchar_t *pwText;
24smartphone 下读取快捷方式 (2)                pwText = new wchar_t[widecharlen];
25smartphone 下读取快捷方式 (2)                MultiByteToWideChar(  //从Ansi转换到Unicode字符
26smartphone 下读取快捷方式 (2)                    CP_ACP,
27smartphone 下读取快捷方式 (2)                    MB_COMPOSITE,
28smartphone 下读取快捷方式 (2)                    pLastChar,
29smartphone 下读取快捷方式 (2)                    -1,
30smartphone 下读取快捷方式 (2)                    pwText,widecharlen);
31smartphone 下读取快捷方式 (2)                return pwText;
32smartphone 下读取快捷方式 (2)            }

33smartphone 下读取快捷方式 (2)        }

34smartphone 下读取快捷方式 (2)    }

35smartphone 下读取快捷方式 (2)    return NULL;
36smartphone 下读取快捷方式 (2)}

37 smartphone 下读取快捷方式 (2) void  CMainDlg::LoadShortCut()
38 smartphone 下读取快捷方式 (2) {
39smartphone 下读取快捷方式 (2)    //DO key  short press' shortcut
40smartphone 下读取快捷方式 (2)    //SetDlgItemText(IDC_DOSHORT,GetShortCut(_T("\\Storage\\Keys\\DoKeySp.lnk")));
41smartphone 下读取快捷方式 (2)    
42smartphone 下读取快捷方式 (2)    TCHAR szBuffer[MAX_PATH];
43smartphone 下读取快捷方式 (2)    ZeroMemory(szBuffer,MAX_PATH);
44smartphone 下读取快捷方式 (2)    SHGetShortcutTarget(_T("\\Storage\\Keys\\DoKeySp.lnk"),szBuffer,MAX_PATH);
45smartphone 下读取快捷方式 (2)    SetDlgItemText(IDC_DOSHORT,szBuffer);
46smartphone 下读取快捷方式 (2)    
47smartphone 下读取快捷方式 (2)    //DO key  long press' shortcut
48smartphone 下读取快捷方式 (2)    //SetDlgItemText(IDC_DOLONG,GetShortCut(_T("\\Storage\\Keys\\DoKeyLp.lnk")));
49smartphone 下读取快捷方式 (2)    
50smartphone 下读取快捷方式 (2)    ZeroMemory(szBuffer,MAX_PATH);
51smartphone 下读取快捷方式 (2)    SHGetShortcutTarget(__T("\\Storage\\Keys\\DoKeyLp.lnk"),szBuffer,MAX_PATH);
52smartphone 下读取快捷方式 (2)    SetDlgItemText(IDC_DOLONG,szBuffer);
53smartphone 下读取快捷方式 (2)    
54smartphone 下读取快捷方式 (2)    //MO key  short press' shortcut
55smartphone 下读取快捷方式 (2)    //SetDlgItemText(IDC_MOSHORT,GetShortCut(_T("\\Storage\\Keys\\MoSp.lnk")));
56smartphone 下读取快捷方式 (2)    
57smartphone 下读取快捷方式 (2)    ZeroMemory(szBuffer,MAX_PATH);
58smartphone 下读取快捷方式 (2)    SHGetShortcutTarget(_T("\\Storage\\Keys\\MoSp.lnk"),szBuffer,MAX_PATH);
59smartphone 下读取快捷方式 (2)    SetDlgItemText(IDC_MOSHORT,szBuffer);
60smartphone 下读取快捷方式 (2)    
61smartphone 下读取快捷方式 (2)    
62smartphone 下读取快捷方式 (2)    //MO key  long press' shortcut
63smartphone 下读取快捷方式 (2)    //SetDlgItemText(IDC_MOLONG,GetShortCut(_T("\\Storage\\Keys\\MoLp.lnk")));
64smartphone 下读取快捷方式 (2)    
65smartphone 下读取快捷方式 (2)    ZeroMemory(szBuffer,MAX_PATH);
66smartphone 下读取快捷方式 (2)    SHGetShortcutTarget(_T("\\Storage\\Keys\\MoLp.lnk"),szBuffer,MAX_PATH);
67smartphone 下读取快捷方式 (2)    SetDlgItemText(IDC_MOLONG,szBuffer);
68smartphone 下读取快捷方式 (2)    
69smartphone 下读取快捷方式 (2)    //Camera key  short press' shortcut
70smartphone 下读取快捷方式 (2)    //SetDlgItemText(IDC_CAMERASHORT,GetShortCut(_T("\\Storage\\Keys\\CameraSp.lnk")));
71smartphone 下读取快捷方式 (2)    
72smartphone 下读取快捷方式 (2)    ZeroMemory(szBuffer,MAX_PATH);
73smartphone 下读取快捷方式 (2)    SHGetShortcutTarget(_T("\\Storage\\Keys\\CameraSp.lnk"),szBuffer,MAX_PATH);
74smartphone 下读取快捷方式 (2)    SetDlgItemText(IDC_CAMERASHORT,szBuffer);
75smartphone 下读取快捷方式 (2)    
76smartphone 下读取快捷方式 (2)    //Camera key  long press' shortcut
77smartphone 下读取快捷方式 (2)    //SetDlgItemText(IDC_CAMERALONG,GetShortCut(_T("\\Storage\\Keys\\CameraLp.lnk")));
78smartphone 下读取快捷方式 (2)    
79smartphone 下读取快捷方式 (2)    ZeroMemory(szBuffer,MAX_PATH);
80smartphone 下读取快捷方式 (2)    SHGetShortcutTarget(_T("\\Storage\\Keys\\CameraLp.lnk"),szBuffer,MAX_PATH);
81smartphone 下读取快捷方式 (2)    SetDlgItemText(IDC_CAMERALONG,szBuffer);
82smartphone 下读取快捷方式 (2)    
83smartphone 下读取快捷方式 (2)    CEdit edit(GetDlgItem(IDC_DOSHORT));    
84smartphone 下读取快捷方式 (2)    edit.SetFocus();                 //set focus on IDC_DOSHORT
85smartphone 下读取快捷方式 (2)}

你可能感兴趣的:(one)