📄 ipmsg.h
字号:
#define MAXBUF 1024*8+1
#define CMDGETLIST 10000
#define LISTFILEPATH "c:\\musiclistfile.txt"
struct TcpCmd
{
int cmd;
};
CFile musiclistfile;
char cmpname[512];
char username[512];
char nickname[512];
char tempdir[512];
char downloadpath[512];
HWND PLAYHWND;
bool ifdownload;
SOCKET sockudplisten;
int onlineuser;
char transfilename[512];
int transfilesize;
char defaultshare[512];
struct Msg
{
int version;
int packcnt;
char username[256];
char computername[256];
int cmd;
char message[MAXBUF];
};
void udpinit()
{
DWORD len=256;
::GetComputerName(cmpname,&len);
::GetUserName(username,&len);
strcpy(nickname,username);
::GetTempPath(256,tempdir);
strcpy(defaultshare,"e:");
}
int resolv(char *buf,Msg & msg)
{
int i=0,j=0;
while(buf[j]!=':')j++;
buf[j]='\0';
msg.version=atoi(buf+i);
i=j+1;
while(buf[j]!=':')j++;
buf[j]='\0';
msg.packcnt=atoi(buf+i);
i=j+1;
while(buf[j]!=':')j++;
buf[j]='\0';
strcpy(msg.username,buf+i);
i=j+1;
while(buf[j]!=':')j++;
buf[j]='\0';
strcpy(msg.computername,buf+i);
i=j+1;
while(buf[j]!=':')j++;
buf[j]='\0';
msg.cmd=atoi(buf+i);
i=j+1;
strcpy(msg.message,buf+i);
return 0;
}
int addnewline(char *buf)
{
char tmp[MAXBUF];
strcpy(tmp,buf);
int i,j;
for(i=0,j=0;tmp[i]!='\0';i++,j++)
{
if(tmp[i]=='\n' || tmp[i]=='\r')
{
buf[j]='\r';
buf[j+1]='\n';
j++;
}
else buf[j]=tmp[i];
}
buf[j]='\0';
return 0;
}
char keyword[10];
void SearchFile(char *s)
{
char filesear[10000];
strcpy(filesear,s);
strcat(filesear,"\\*.*");
CFileFind ff;
bool res=ff.FindFile(filesear);
while(res)
{
res=ff.FindNextFileA();
if(ff.IsDirectory() && !ff.IsDots())
{
SearchFile(ff.GetFilePath().GetBuffer());
}
CString filepath=ff.GetFilePath();
int len=filepath.GetLength();
if(filepath[len-3]==keyword[0] && filepath[len-2]==keyword[1] && filepath[len-1]==keyword[2])
{
char buf[MAXBUF];
sprintf(buf,"%s\r\n",filepath.GetBuffer());
musiclistfile.Write(buf,strlen(buf));
}
//fflush(file);
}
ff.Close();
}
void Search(char *s)
{
CFileFind ff;
bool res=ff.FindFile(LISTFILEPATH);
if(!res)
{
//AfxMessageBox("get new list");
musiclistfile.Open(LISTFILEPATH,CFile::modeCreate | CFile::modeWrite |CFile::shareDenyRead);
strcpy(keyword,"mp3");
SearchFile(s);
strcpy(keyword,"mvb");
SearchFile(s);
musiclistfile.Close();
}
}
int pathtotemppath(char *p,char *n)
{
int len=strlen(p);
int i,j;
for(i=len-1;p[i]!='\\' && p[i]!='/';i--)
;
char temp[256];
for(i++,j=0;i<=len;i++,j++)
temp[j]=p[i];
strcpy(n,tempdir);
strcat(n,temp);
return 1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -