smartphone 创建快捷方式 shorcut(1)

当然可以使用

SHCreateShortcut 来创建快捷方式,但是我尝试着总是不成功,只好自己写一个了

/*******************************************************
  smartphone 快捷方式介绍
  快捷方式分3部分,形式如 XX#XXXXXXXXXXXXXXXXXXX
  #号前面为#号后面的长度,即命令行的长度
  程序名称必须用双引号括起来,参数写到双引号后面

  例如:
  54#"\Storage Card\PhoneSharp\PhoneSharp.exe" -callhistory
  若中间没有空格也可以不用双引号,但为了保成通用还是有必要加上双引号
  iHqq QQ:6966683
 
*****************************************************/

smartphone 创建快捷方式 shorcut(1) BOOL CMainDlg::CreateShortCut(LPCTSTR strFileName,TCHAR *  path)
smartphone 创建快捷方式 shorcut(1)

smartphone 创建快捷方式 shorcut(1) 
char szBuffer[255];
smartphone 创建快捷方式 shorcut(1) ZeroMemory(szBuffer, 
sizeof(szBuffer));
smartphone 创建快捷方式 shorcut(1)
smartphone 创建快捷方式 shorcut(1) 
if(_tcslen(path))
smartphone 创建快捷方式 shorcut(1) 
{
smartphone 创建快捷方式 shorcut(1)  
int multicharlen = WideCharToMultiByte(CP_ACP,0,path,-1,NULL,0,NULL,NULL);
smartphone 创建快捷方式 shorcut(1)  
char* pMultiText;
smartphone 创建快捷方式 shorcut(1)  pMultiText 
= new char[multicharlen];
smartphone 创建快捷方式 shorcut(1)  WideCharToMultiByte(CP_ACP,
0,path,-1,pMultiText,multicharlen,NULL,NULL);
smartphone 创建快捷方式 shorcut(1)  sprintf(szBuffer,
"%d#%s",multicharlen-1,pMultiText);
smartphone 创建快捷方式 shorcut(1) }

smartphone 创建快捷方式 shorcut(1) 
else
smartphone 创建快捷方式 shorcut(1) 
{
smartphone 创建快捷方式 shorcut(1)  sprintf(szBuffer,
"%s","10#\":MSINBOX\"");
smartphone 创建快捷方式 shorcut(1) }

smartphone 创建快捷方式 shorcut(1) HANDLE hFile 
= CreateFile(strFileName,GENERIC_WRITE,FILE_SHARE_READ,
smartphone 创建快捷方式 shorcut(1)  NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
smartphone 创建快捷方式 shorcut(1) 
if(hFile != INVALID_HANDLE_VALUE)
smartphone 创建快捷方式 shorcut(1) 
{
smartphone 创建快捷方式 shorcut(1)  DWORD dwNumToWrite;  
smartphone 创建快捷方式 shorcut(1)  WriteFile(hFile,szBuffer,strlen(szBuffer),
&dwNumToWrite,0);  
smartphone 创建快捷方式 shorcut(1)  CloseHandle(hFile);
smartphone 创建快捷方式 shorcut(1)  
return TRUE;   
smartphone 创建快捷方式 shorcut(1) }

smartphone 创建快捷方式 shorcut(1) 
return FALSE;  
smartphone 创建快捷方式 shorcut(1)}

smartphone 创建快捷方式 shorcut(1)LRESULT CMainDlg::SaveShortCut(WORD 
/*wNotifyCode*/ , WORD  /*wID*/ , HWND  /*hWndCtl*/ , BOOL &   /*bHandled*/ )
smartphone 创建快捷方式 shorcut(1)
{
smartphone 创建快捷方式 shorcut(1) TCHAR szBuffer[
255];            // buffer for receives data
smartphone 创建快捷方式 shorcut(1) 
smartphone 创建快捷方式 shorcut(1) 
//DO key  short press' shortcut
smartphone 创建快捷方式 shorcut(1)
 ZeroMemory(szBuffer, sizeof(szBuffer));
smartphone 创建快捷方式 shorcut(1) GetDlgItemText(IDC_DOSHORT,szBuffer,
255);
smartphone 创建快捷方式 shorcut(1) 
if(!CreateShortCut(_T("\\Storage\\Keys\\DoKeySp.lnk"),szBuffer))
smartphone 创建快捷方式 shorcut(1) 
{
smartphone 创建快捷方式 shorcut(1)  MessageBox(_T(
"创建快捷方式 \\Storage\\Keys\\DoKeySp.lnk 出错"),_T("出错了!"),MB_OK);
smartphone 创建快捷方式 shorcut(1)  
return FALSE;
smartphone 创建快捷方式 shorcut(1) }

smartphone 创建快捷方式 shorcut(1) 
smartphone 创建快捷方式 shorcut(1) 
//DO key  long press' shortcut
smartphone 创建快捷方式 shorcut(1)
 ZeroMemory(szBuffer, sizeof(szBuffer));
smartphone 创建快捷方式 shorcut(1) GetDlgItemText(IDC_DOLONG,szBuffer,
255);
smartphone 创建快捷方式 shorcut(1) 
if(!CreateShortCut(_T("\\Storage\\Keys\\DoKeyLp.lnk"),szBuffer))
smartphone 创建快捷方式 shorcut(1) 
{
smartphone 创建快捷方式 shorcut(1)  MessageBox(_T(
"创建快捷方式 \\Storage\\Keys\\DoKeyLp.lnk 出错"),_T("出错了!"),MB_OK);
smartphone 创建快捷方式 shorcut(1)  
return FALSE;
smartphone 创建快捷方式 shorcut(1) }

smartphone 创建快捷方式 shorcut(1) 
smartphone 创建快捷方式 shorcut(1) 
//MO key  short press' shortcut
smartphone 创建快捷方式 shorcut(1)
 ZeroMemory(szBuffer, sizeof(szBuffer));
smartphone 创建快捷方式 shorcut(1) GetDlgItemText(IDC_MOSHORT,szBuffer,
255);
smartphone 创建快捷方式 shorcut(1) 
if(!CreateShortCut(_T("\\Storage\\Keys\\MoSp.lnk"),szBuffer))
smartphone 创建快捷方式 shorcut(1) 
{
smartphone 创建快捷方式 shorcut(1)  MessageBox(_T(
"创建快捷方式 \\Storage\\Keys\\MoSp.lnk出错"),_T("出错了!"),MB_OK);
smartphone 创建快捷方式 shorcut(1)  
return FALSE;
smartphone 创建快捷方式 shorcut(1) }

smartphone 创建快捷方式 shorcut(1) 
smartphone 创建快捷方式 shorcut(1) 
//MO key  long press' shortcut
smartphone 创建快捷方式 shorcut(1)
 ZeroMemory(szBuffer, sizeof(szBuffer));
smartphone 创建快捷方式 shorcut(1) GetDlgItemText(IDC_MOLONG,szBuffer,
255);
smartphone 创建快捷方式 shorcut(1) 
if(!CreateShortCut(_T("\\Storage\\Keys\\MoLp.lnk"),szBuffer))
smartphone 创建快捷方式 shorcut(1) 
{
smartphone 创建快捷方式 shorcut(1)  MessageBox(_T(
"创建快捷方式 \\Storage\\Keys\\MoLp.lnk 出错"),_T("出错了!"),MB_OK);
smartphone 创建快捷方式 shorcut(1)  
return FALSE;
smartphone 创建快捷方式 shorcut(1) }

smartphone 创建快捷方式 shorcut(1) 
//Camera key  short press' shortcut
smartphone 创建快捷方式 shorcut(1)
 ZeroMemory(szBuffer, sizeof(szBuffer));
smartphone 创建快捷方式 shorcut(1) GetDlgItemText(IDC_CAMERASHORT,szBuffer,
255);
smartphone 创建快捷方式 shorcut(1) 
if(!CreateShortCut(_T("\\Storage\\Keys\\CameraSp.lnk"),szBuffer))
smartphone 创建快捷方式 shorcut(1) 
{
smartphone 创建快捷方式 shorcut(1)  MessageBox(_T(
"创建快捷方式 \\Storage\\Keys\\CameraSp.lnk 出错"),_T("出错了!"),MB_OK);
smartphone 创建快捷方式 shorcut(1)  
return FALSE;
smartphone 创建快捷方式 shorcut(1) }

smartphone 创建快捷方式 shorcut(1) 
//Camera key  long press' shortcut
smartphone 创建快捷方式 shorcut(1)
 ZeroMemory(szBuffer, sizeof(szBuffer));
smartphone 创建快捷方式 shorcut(1) GetDlgItemText(IDC_CAMERALONG,szBuffer,
255);
smartphone 创建快捷方式 shorcut(1) 
if(!CreateShortCut(_T("\\Storage\\Keys\\CameraLp.lnk"),szBuffer))
smartphone 创建快捷方式 shorcut(1) 
{
smartphone 创建快捷方式 shorcut(1)  MessageBox(_T(
"创建快捷方式 \\Storage\\Keys\\CameraLp.lnk 出错"),_T("出错了!"),MB_OK);
smartphone 创建快捷方式 shorcut(1)  
return FALSE;
smartphone 创建快捷方式 shorcut(1) }

smartphone 创建快捷方式 shorcut(1) MessageBox(_T(
"已经成功创建快捷方式!赶快试试吧!"),_T("提示!"),MB_OK);
smartphone 创建快捷方式 shorcut(1) 
return TRUE;
smartphone 创建快捷方式 shorcut(1)}

smartphone 创建快捷方式 shorcut(1)

你可能感兴趣的:(cut)