怎么才能编写能使用脚本调用的组件?
如何才能编写能使用脚本调用的组件?????
我正在学习atl编程,自己写了一个组件在新的ie窗口中打开google搜索,我建了ie右键菜单,调用一个脚本才执行组件,但是在我运行脚本时总是显示“缺少在ieGoogle对象”
我的脚本是
<script language= "VBScript ">
'Great thanks to Vladimir Romanov(Author of ReGet Pro)
'Download selected link
Sub AddLink(Url)
'On Error Resume Next
set ieGoogle=CreateObject( "GoogleSearch.DoSearch ")
if err <> 0 then
MsgBox( "ieGoogle not properly installed! "+ vbCrLf+ "Please install ieGoogle again ")
else
'MsgBox( "ieGoogle create! ")
call ieGoogle.Search( "Heool! ")
end if
end sub
call AddLink(Url)
</script>
但是我在终端程序里面测试我的组件确实能够打开googel搜索
#include <windows.h>
#include <tchar.h>
#include <iostream.h>
#include <initguid.h>
#include "iostream "
#include "GoogleSearch\GoogleSearch_i.c "
#include "GoogleSearch\GoogleSearch.h "
int main(int argc,char* argv[])
{
cout < < "Initializing COM " < <endl;
if(FAILED(CoInitialize(NULL)))
{
cout < < "Intialize error " < <endl;
return -1;
}
IDoSearch* pFun;
HRESULT hr=CoCreateInstance(CLSID_DoSearch,NULL,CLSCTX_INPROC,IID_IDoSearch,(void**) &pFun);
if(FAILED(hr))
{
cout < < "create error! " < <endl;
return -1;
}
cout < < "Create! " < <endl;
pFun-> Search(::SysAllocString(L "Hello,World! "));
getchar();
pFun-> Release();
cout < < "shut down! " < <endl;
CoUninitialize();
return 0;
}
请高手给我指点迷津,因为我才开始学,很多东西还不明白
------解决方案--------------------
你的组件需要从IDispatch接口继承
才能被脚本语言调用
------解决方案--------------------
对的,需要从IDispatch接口继承.否则脚本语言中无法使用.
------解决方案--------------------
还有GoogleSearch.DoSearch这个是你定义的progid么?
我正在学习atl编程,自己写了一个组件在新的ie窗口中打开google搜索,我建了ie右键菜单,调用一个脚本才执行组件,但是在我运行脚本时总是显示“缺少在ieGoogle对象”
我的脚本是
<script language= "VBScript ">
'Great thanks to Vladimir Romanov(Author of ReGet Pro)
'Download selected link
Sub AddLink(Url)
'On Error Resume Next
set ieGoogle=CreateObject( "GoogleSearch.DoSearch ")
if err <> 0 then
MsgBox( "ieGoogle not properly installed! "+ vbCrLf+ "Please install ieGoogle again ")
else
'MsgBox( "ieGoogle create! ")
call ieGoogle.Search( "Heool! ")
end if
end sub
call AddLink(Url)
</script>
但是我在终端程序里面测试我的组件确实能够打开googel搜索
#include <windows.h>
#include <tchar.h>
#include <iostream.h>
#include <initguid.h>
#include "iostream "
#include "GoogleSearch\GoogleSearch_i.c "
#include "GoogleSearch\GoogleSearch.h "
int main(int argc,char* argv[])
{
cout < < "Initializing COM " < <endl;
if(FAILED(CoInitialize(NULL)))
{
cout < < "Intialize error " < <endl;
return -1;
}
IDoSearch* pFun;
HRESULT hr=CoCreateInstance(CLSID_DoSearch,NULL,CLSCTX_INPROC,IID_IDoSearch,(void**) &pFun);
if(FAILED(hr))
{
cout < < "create error! " < <endl;
return -1;
}
cout < < "Create! " < <endl;
pFun-> Search(::SysAllocString(L "Hello,World! "));
getchar();
pFun-> Release();
cout < < "shut down! " < <endl;
CoUninitialize();
return 0;
}
请高手给我指点迷津,因为我才开始学,很多东西还不明白
------解决方案--------------------
你的组件需要从IDispatch接口继承
才能被脚本语言调用
------解决方案--------------------
对的,需要从IDispatch接口继承.否则脚本语言中无法使用.
------解决方案--------------------
还有GoogleSearch.DoSearch这个是你定义的progid么?