DragQueryFile始终返回0

时间:2017-08-27 08:05:45

标签: vba powerpoint-vba

我在PowerPoint中使用VBA尝试剪贴板中的访问文件,但DragQueryFile始终返回0.

我的代码剪断了

def match_bigrams(row):
    categories = []

    for bigram in row.bigram:
        joined = ' '.join(list(bigram))
        if joined in Recreation:
            categories.append(joined)

    return categories

df['Recreation_Amenities'] = df.apply(match_bigrams, axis=1)
print(df)


Id  bigram  Recreation_Amenities
0   1952043 [(Swimming, Pool), (Pool, in), (in, the), (the...   [Swimming Pool]
1   1918916 [(Luxury, Apartments), (Apartments, consisting...   [Luxury Apartments]
2   1645751 [(Flat, available), (available, sale), (sale, ...   []
3   1270503 [(Toddler, Pool), (Pool, with), (with, Jogging...   [Toddler Pool, Jogging Tracks]
4   1495638 [(near, medavakkam), (medavakkam, junction), (...   []

我在Windows 10和Office 2013上。

C#(DragQueryFile returns 0 when I try to get file count?)有类似的帖子,但我已经将OpenClipboard称为CloseClipboard。

感谢任何帮助。

1 个答案:

答案 0 :(得分:0)

我根据 tmp_hallenser 的评论得到了它,但我认为最好将其布局得更清楚。

应该改变这两个函数定义:

Private Declare PtrSafe Function GetClipboardData Lib "user32" (ByVal uFormat As Long) As LongPtr
Private Declare PtrSafe Function DragQueryFile Lib "shell32.dll" Alias "DragQueryFileA" ( ByVal HDROP As LongPtr, ByVal UINT As Long, ByVal lpStr As String, ByVal ch As Long) As Long

这是必要的,因为 HDROP 是一个内存地址,因此根据系统大小不同。

LongPtr will always be the appropriate size 类型。