[每日一码] Get path of file on clipboard
static void asdkMyGroupMyCommand(){
HWND m采用hWnd=NULL;
if (::OpenClipboard(m采用hWnd))
{
UINT clipboard采用format=0;
char dwg[]=".DWG";
while ((clipboard采用format = EnumClipboardFormats(clipboard采用format))!=0)
{
HGLOBAL global采用memory = GetClipboardData(clipboard采用format);
tagClipboardInfo* clipboard采用data = (tagClipboardInfo *)GlobalLock(global采用memory);
if (clipboard采用data != NULL && GlobalSize(clipboard采用data) == sizeof(tagClipboardInfo))
{
char tempFile={'\0'};
sprintf(tempFile,"%s",clipboard采用data);
if (strlen(tempFile)>5 && strstr(tempFile,dwg) !=NULL)
{
if (strcmp(tempFile,dwg)>0)
{
acutPrintf("\nOk, temp file= %s",tempFile);
GlobalUnlock(global采用memory);
::CloseClipboard();
return;
}
}
}
GlobalUnlock(global采用memory);
}
acutPrintf("\nNo AutoCAD clipboard entity!");
::CloseClipboard();
}
else
{
acutPrintf("\nCan not open Clipboard!");
}
}
页:
[1]