<分区>
标题中描述了问题。
我有两个功能。首先我得到文件名(变量 text
),但该函数没有返回预期值。返回值 text
后,它变成了 abrakadabra。但是在第二个函数中变量 text
被正确返回。任何帮助将不胜感激。
char* GetCurrentClipboardData(...)
{
char* text;
wchar_t file[MAX_PATH];
if( OpenClipboard(NULL) )
{
HGLOBAL hFile = (HGLOBAL)GetClipboardData(CF_HDROP);
if (hFile)
{
HDROP hDrop = (HDROP)GlobalLock(hFile);
DragQueryFile(hDrop, 0, file, MAX_PATH);
_bstr_t b(file);
text = b;
if (text != Text)
{
SaveDataToFile (file_path, current_time, text);
char* copy = ReadFile(shadowcopy_path);
if (copy == "1")
MakeFileShadowCopy(file, shadowcopies);
}
GlobalUnlock(hFile);
}
HBITMAP hBitmap = (HBITMAP)GetClipboardData(CF_BITMAP);
if (hBitmap)
{
text = "Изображение";
if (text != Text)
{
SaveDataToFile (image_path, current_time, text);
char* copy = ReadFile(shadowcopy_path);
if (copy == "1")
MakeImageShadowCopy(hBitmap, shadowcopies, current_date, current_time);
}
GlobalUnlock(hBitmap);
}
CloseClipboard();
}
return text;
}