ShellExecute的用法
我用ShellExecute,写了一个百度搜歌的程序。但为什么当我在我的词条上打上中文时搜出来的歌会乱码,而我用拼音打歌名时却能搜出歌曲来呢。程序如下;#include "stdafx.h"
#include <windows.h>
#include <windowsx.h>
#include <shellapi.h>
#include "resource.h"
#include "MainDlg.h"
BOOL WINAPI Main_Proc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
HANDLE_MSG(hWnd, WM_INITDIALOG, Main_OnInitDialog);
HANDLE_MSG(hWnd, WM_COMMAND, Main_OnCommand);
HANDLE_MSG(hWnd,WM_CLOSE, Main_OnClose);
}
return FALSE;
}
BOOL Main_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
{
return TRUE;
}
void Main_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
{
switch(id)
{
case IDC_OK:
{
TCHAR musiconline[256];
GetDlgItemText(hwnd,IDC_EDIT1,musiconline,sizeof(musiconline)/sizeof(TCHAR));
TCHAR musiconline1[256];
wsprintf(musiconline1,"http://mp3.baidu.com/m?f=ms&tn=baidump3&ct=134217728&lf=&rn=&word=%s&lm=-1",musiconline);
ShellExecute(hwnd,"open",musiconline1,NULL,NULL,SW_SHOWNORMAL);
}
break;
default:
break;
}
}
void Main_OnClose(HWND hwnd)
{
EndDialog(hwnd, 0);
}