H
hunter0401
Unregistered / Unconfirmed
GUEST, unregistred user!
在一个接口中申明的方法如下VC++)
interface IRMNavigator : public IUnknown
{
public:
// IUnknown methods.
...//我省略其他
STDMETHOD(SetSearchExtensions) (LPBSTR lpExtensions, BYTE bItems) PURE;
...//我省略其他
};
在VC++的DEMO中是这样使用的
void CMainWnd::OnSetSearchExtensions()
{
if(!m_pnav)
{
MessageBox(NULL, TEXT("No navigator"), TEXT("Error"), MB_OK);
return;
}
LPBSTR lpExtItems;
TCHAR *szItems[] =
{
TEXT("dat"),
TEXT("mp2"),
TEXT("mpa")
};
BYTE items = sizeof(szItems) / sizeof(szItems[0]);
lpExtItems = (LPBSTR) calloc(items, sizeof(BSTR));
if(!lpExtItems)
return;
// To allocate BSTRs
WCHAR wszFile[MAX_PATH];
for(int i = 0; i < items; i++)
{
// Here I should be calculating the size of then required buffer by calling
// MultiByteToWideChar with the last parameter to 0, allocate buffer accordingly
// and then calling MultiByteToWideChar again with this value instead of MAX_PATH
if(MultiByteToWideChar(CP_ACP, 0, szItems, -1, wszFile, MAX_PATH))
lpExtItems = SysAllocString(wszFile);
}
m_hResult = m_pnav->SetSearchExtensions(lpExtItems, items);
// Free strings
for(i = 0; i < items; i++)
SysFreeString(lpExtItems);
HELPER_FREE(lpExtItems);
if(FAILED(m_hResult))
{
lstrcpy(m_szResult, TEXT("OnSetSearchExtensions() - SetSearchExtensions() Failed"));
RETURN_ERROR;
}
RETURN_CLEAR;
}
我现在要在DELPHI下使用这个接口,请问LPBSTR应该对应DELPHI中什么类型?
interface IRMNavigator : public IUnknown
{
public:
// IUnknown methods.
...//我省略其他
STDMETHOD(SetSearchExtensions) (LPBSTR lpExtensions, BYTE bItems) PURE;
...//我省略其他
};
在VC++的DEMO中是这样使用的
void CMainWnd::OnSetSearchExtensions()
{
if(!m_pnav)
{
MessageBox(NULL, TEXT("No navigator"), TEXT("Error"), MB_OK);
return;
}
LPBSTR lpExtItems;
TCHAR *szItems[] =
{
TEXT("dat"),
TEXT("mp2"),
TEXT("mpa")
};
BYTE items = sizeof(szItems) / sizeof(szItems[0]);
lpExtItems = (LPBSTR) calloc(items, sizeof(BSTR));
if(!lpExtItems)
return;
// To allocate BSTRs
WCHAR wszFile[MAX_PATH];
for(int i = 0; i < items; i++)
{
// Here I should be calculating the size of then required buffer by calling
// MultiByteToWideChar with the last parameter to 0, allocate buffer accordingly
// and then calling MultiByteToWideChar again with this value instead of MAX_PATH
if(MultiByteToWideChar(CP_ACP, 0, szItems, -1, wszFile, MAX_PATH))
lpExtItems = SysAllocString(wszFile);
}
m_hResult = m_pnav->SetSearchExtensions(lpExtItems, items);
// Free strings
for(i = 0; i < items; i++)
SysFreeString(lpExtItems);
HELPER_FREE(lpExtItems);
if(FAILED(m_hResult))
{
lstrcpy(m_szResult, TEXT("OnSetSearchExtensions() - SetSearchExtensions() Failed"));
RETURN_ERROR;
}
RETURN_CLEAR;
}
我现在要在DELPHI下使用这个接口,请问LPBSTR应该对应DELPHI中什么类型?