Peercast也可以从命令行启动,有如下几种参数选择
Peercast:正常方式启动
Peercast -inifile:启动,并设置配置文件参数
Peercast -kill:启动后立即关闭
Peercast -url:按照频道的URL地址启动Peercast并播放相应电台
Peercast -multi:以非互斥方式启动
具体实现如下:
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
char tmpURL[8192];
tmpURL[0]=0;
char *chanURL=NULL; //频道地址
iniFileName.set(".//peercast.ini");
// off by default now
showGUI = false; //初始化时不打开图形窗口
//根据命令行参数进行处理
if (strlen(lpCmdLine) > 0)
{
char *p;
if ((p = strstr(lpCmdLine,"-inifile"))!=NULL)
iniFileName.setFromString(p+8);
if (strstr(lpCmdLine,"-zen"))
showGUI = false;
if (strstr(lpCmdLine,"-multi"))
allowMulti = true;
if (strstr(lpCmdLine,"-kill"))
killMe = true;
if ((p = strstr(lpCmdLine,"-url"))!=NULL)
{
p+=4;
while (*p)
{
if (*p=='"')
{
p++;
break;
}
if (*p != ' ')
break;
p++;
}
if (*p)
strncpy(tmpURL,p,sizeof(tmpURL)-1);
}
}
// get current path
{
exePath = iniFileName;
char *s = exePath.cstr();
char *end = NULL;
while (*s)
{
if (*s++ == '//')
end = s;
}
if (end)
*end = 0;
}
if (strnicmp(tmpURL,"peercast://",11)==0)
{
if (strnicmp(tmpURL+11,"pls/",4)==0)
chanURL = tmpURL+11+4;
else
chanURL = tmpURL+11;
showGUI = false;
}