- //获取当前粘贴板数据
- //利用场景,用于半自动化,如获取要执行的代码,脚本上传执行,获取返回结果等
- if ( OpenClipboard(NULL) )
- {
- HANDLE hData = GetClipboardData(CF_TEXT);
- char* buffer = (char*)GlobalLock(hData);
- string sRet = buffer;
- GlobalUnlock(hData);
- CloseClipboard();
- FILE * fp;
- int nRet = fopen_s(&fp,argv[1],"w");
- if(nRet)
- {
- printf("open %s failed",argv[1]);
- return -1;
- }
- fwrite(sRet.c_str(),sRet.length(),1,fp);
- fclose(fp);
- }
- else
- printf("error,open clipboard failed!\n");