|
Try SDK sample program. If you could get it to work, you will know the problem of your program. For my experience, your registry should set it right. If you do not copy your DLL to system directory, you need to modify HKEY_CLASSES_ROOT\CLSID\{your uuid}\InfoProcServer32\Default point to your shell extension dll. Good luck.
!@#$%^&*()_+
|
|
|
|
|
I have a windowless control for which I need a timer to reset an internal state after a short delay, for highlighting purposes.
I have been led to believe that all I need to do is to use a hidden window to handle SetTimer and KillTimer.
Yet all my attempts to create a hidden window have failed. It seems that I can't register my own window class, because Create fails. (This approach worked fine until I specified a variable to refer to the control in C++ code.) So I tried using a predefined class, CButton. This can't be created when the control is used from VBasic, as CWin::Create needs to know have an application instance, but VBasic supplies this as NULL.
I have found code using ATL which would seem to work, but I am using MFC and can't figure out how the ATL code can be translated.
Is there any practical way to use a timer in a windowless control? Or do I really have to specify a window for the control just for the sake of a timer?
Shraddhan
Tearing my hair out does not help me write better code, but it does ease the pain...
|
|
|
|
|
Did you try RegisterClass() /RegisterClassEx() ?
If your target platform is windows 2000 and later, you can create message only windows. They work like windows, except they have no graphical representations. They're just "identities" (HWND).
Good music: In my rosary[^]
|
|
|
|
|
I was using AfxRegisterClass() and CWnd::CreateEx()
After changing the code to use RegisterClassEx( ) and CreateWindowEx(), everything now seems to work.
What the difference might be, I have no idea.
Thanks for the clue.
Shraddhan
|
|
|
|
|
You're most welcome, and I'm glad that it worked out for you.
Good music: In my rosary[^]
|
|
|
|
|
Hi,
How can I load a char** into a VARIANT?
thanks
|
|
|
|
|
Hello bvais,
I assume that you want to use a VARIANT to store a receiver of a string. You can't load a char** into a VARIANT. The standard way to pass strings in COM is to use BSTRs.
Try using a BSTR* instead. In this case, the type for your VARIANT would be : (VT_BSTR|VT_BY_REF). The specific member in the VARIANT to use is "pbstrVal" (set/get via the V_BSTRREF() macro).
Best of luck,
Bio.
|
|
|
|
|
Hi Bio,
I need to pass an array of strings. How do I do that?
|
|
|
|
|
|
Hello bvais,
Yes, as mentioned by GuimaSun (in an earlier reply), the way to do this is to use a SAFEARRAY of BSTRs.
I have a sample function below that can help you to achieve this :
// CreateSafeArrayFromBSTRArray()
// This function will create a SafeArray of BSTRs using the BSTR elements
// found inside
// the first parameter "pBSTRArray".
//
// Note well that the output SafeArray will contain COPIES of the original
// BSTRs
// inside the input parameter "pBSTRArray".
//
long CreateSafeArrayFromBSTRArray
(
BSTR* pBSTRArray,
ULONG ulArraySize,
SAFEARRAY** ppSafeArrayReceiver
)
{
HRESULT hrRetTemp = S_OK;
SAFEARRAY* pSAFEARRAYRet = NULL;
SAFEARRAYBOUND rgsabound[1];
ULONG ulIndex = 0;
long lRet = 0;
// Initialise receiver.
if (ppSafeArrayReceiver)
{
*ppSafeArrayReceiver = NULL;
}
if (pBSTRArray)
{
rgsabound[0].lLbound = 0;
rgsabound[0].cElements = ulArraySize;
pSAFEARRAYRet = (SAFEARRAY*)SafeArrayCreate
(
(VARTYPE)VT_BSTR,
(unsigned int)1,
(SAFEARRAYBOUND*)rgsabound
);
}
for (ulIndex = 0; ulIndex < ulArraySize; ulIndex++)
{
long lIndexVector[1];
lIndexVector[0] = ulIndex;
// Since pSAFEARRAYRet is created as a SafeArray of VT_BSTR,
// SafeArrayPutElement() will create a copy of each BSTR
// inserted into the SafeArray.
SafeArrayPutElement
(
(SAFEARRAY*)pSAFEARRAYRet,
(long*)lIndexVector,
(void*)(pBSTRArray[ulIndex])
);
}
if (pSAFEARRAYRet)
{
*ppSafeArrayReceiver = pSAFEARRAYRet;
}
return lRet;
}
Then, you can use the above function in your code as demonstrated below :
#include <comdef.h>
int main()
{
// Define an array of BSTRs which are initialized via _bstr_t.
BSTR bstrArray[] =
{
_bstr_t(L"BSTR 01").copy(),
_bstr_t(L"BSTR 02").copy(),
_bstr_t(L"BSTR 03").copy(),
_bstr_t(L"BSTR 04").copy(),
_bstr_t(L"BSTR 05").copy()
};
SAFEARRAY* pSAFEARRAY = NULL;
// Create a Safe Array of BSTRs which are copies of the elements
// of bstrArray.
CreateSafeArrayFromBSTRArray
(
bstrArray,
sizeof(bstrArray)/sizeof(BSTR),
&pSAFEARRAY
);
// Destroy the safe array object pSAFEARRAY.
// SafeArrayDestroy() will also destroy the
// BSTRs created via CreateSafeArrayFromBSTRArray().
// pSAFEARRAY.
SafeArrayDestroy(pSAFEARRAY);
pSAFEARRAY = NULL;
return 0;
}
Best Regards,
Bio.
|
|
|
|
|
Lim Bio Liong wrote:
_bstr_t(L"BSTR 01").copy()
Just out of curiosity.. why this, when there's SysAllocString() ?
Good music: In my rosary[^]
|
|
|
|
|
Hello Jorgen,
Yes, Jorgen, SysAllocString() should be used. I recently used _bstr_t in a similar manner (for R&D purposes) as the sample code for bvais and developed something of a habit .
Thanks for pointing it out, Jorgen.
Best Regards,
Bio.
|
|
|
|
|
I am using TotalRecorder(ww.highcriteria.com) in my application developed in C#. My Application inetract with TotalRecorder through COM. Total Recorder provides a sample in VC 6.0 for saving the recorded file at a specified folder location. I have converted the VC 6.0 code to C#, everything is working fine except when i call the method that saves the recorded files, the method takes variant as input, while the wrapper for this method generated by VS 2003 takes object as input. I passed him with the required parameters but it gives error 'Method Not Implemented'. Both the codes are given below. Please help me in conerting this VC code (variants) to C# (objects)
This is the code in VC 6.0
_variant_t vartFileName;
VARIANT vFmt;
vartFileName = cFileName;
vFmt.vt = VT_ERROR;
vFmt.scode = DISP_E_PARAMNOTFOUND;
g_pTRDoc->SaveAs(vartFileName, vFmt);
I have converted this in C# like this
string FileName = "c:\test.wav";
rec.ActiveDocument.SaveAs(FileName,System.Reflection.Missing.Value);
Thanks
I am using TotalRecorder(ww.highcriteria.com) in my application developed in C#. My Application inetract with TotalRecorder through COM. Total Recorder provides a sample in VC 6.0 for saving the recorded file at a specified folder location. I have converted the VC 6.0 code to C#, everything is working fine except when i call the method that saves the recorded files, the method takes variant as input, while the wrapper for this method generated by VS 2003 takes object as input. I passed him with the required parameters but it gives error 'Method Not Implemented'. Both the codes are given below. Please help me in conerting this VC code (variants) to C# (objects)
This is the code in VC 6.0
_variant_t vartFileName;
VARIANT vFmt;
vartFileName = cFileName;
vFmt.vt = VT_ERROR;
vFmt.scode = DISP_E_PARAMNOTFOUND;
g_pTRDoc->SaveAs(vartFileName, vFmt);
I have converted this in C# like this
string FileName = "c:\test.wav";
rec.ActiveDocument.SaveAs(FileName,System.Reflection.Missing.Value);
Thanks
Basit Tanveer
Software Engineer
|
|
|
|
|
|
U have the source code ? If yes u can debug using dll host !
|
|
|
|
|
hi all
i have 2 .lib files related to one com server . the first is to make connection with the server and the latter is for sending and recieving data .
i have created an instance for the first by :
<br />
MULTI_QI qi[] = { & __uuidof(IserverSys) , 0, 0} ;<br />
<br />
COSERVERINFO serverinfo;<br />
COSERVERINFO *pServerInfo = 0;<br />
memset( &serverinfo, 0, sizeof( COSERVERINFO ) );<br />
<br />
serverinfo.pwszName = NULL;
pServerInfo = &serverinfo;<br />
serverinfo.pAuthInfo=NULL;<br />
{<br />
hr = ::CoCreateInstanceEx( <br />
__uuidof(serverSys) , <br />
0, <br />
CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER ,<br />
pServerInfo, <br />
1, <br />
qi<br />
);<br />
if( ( FAILED(qi[0].hr) ) || ( FAILED(hr) ) )<br />
{ <br />
AfxMessageBox(" Could not create instance of server");<br />
return ;<br />
}<br />
g_pIserverSys = (IserverSys *) qi[0].pItf;<br />
do i have to do the same for the latter ? if not what do i must do to create an object for the latter?
|
|
|
|
|
Is it possibly to obain currently active IE window using IShellWindows. I can get the list of open explorer windows using get_Count() function that's about it.
What I want is to keep track of multiple opened IE windows, so that if the window becomes active (a user navigates to a new site, etc) I can jusp directly to it, retreive and retreive the document witout cycling through all opened IE windows.
Thank you
|
|
|
|
|
Are you writing a BHO ? If so you could sink events from IWebBrowserEvents2 interface to get notified from new browser windows and page navigation, there's a lot of articles on codeproject describing how to do it.
I hope it helps,
GuimaSun
www.nexsun.com.br
NEXSUN TechZone
|
|
|
|
|
i have a com class in an mfc dialog based app that recieves data from an out of process com server . i want to send the reciveing data to a dialog to show it . what is the best way ? posting message or another ?
|
|
|
|
|
A general solution is to launch an event with data from the COM object, that event would be subscribed by the MFC client which get the data and may show it.
GuimaSun
www.nexsun.com.br
NEXSUN TechZone
|
|
|
|
|
Hello, I hope I am posting this in the right place.
I am writing a website using Asp.Net and I am trying to use a COM written in FoxPro. I have compiled the COM as a multi-threaded dll and added it as a reference. When I try to instantiate it (e.g. myserver.myclass comObject = new myclass() ), I get a InteropServices.COMException and the Message is simply "Exception Occurred". Does anyone know what I might be doing wrong, or any way I can get more information out of the exception? I tried printing the HRESULT and I get -2146352567.
Any help would be appreciated.
Thanks
BCKY
|
|
|
|
|
Hi all
I am writng an application in mfc which have to monitor the internet explorer
and to get the x and y coordinates of the caret position.
I already knows how to get IHTMLDocument2 from the HWND
but was not able to figure out how to get the position of the caret inside the document.
i understood that the IHTMLCaret cannot be retrieve because my application is in a different process.
So what is the solution for this
i will be very happey to hear any suggestion because i am stuck with this problem for almost two weeks
now.
|
|
|
|
|
Hi all ,
I have created an instance of a COM+ component in another component . All works extremely fine in Debug Version but when compiled in Release version , the Release (.Release()) of the component gives an access violation exception .
Can anyone please help me solve this problem .
Thanks and Best Regards,
Amey
|
|
|
|
|
|
Hi GaimaSun ,
Ya, tht's the first thing tht i've tried , problem is that there memory corruption somewhere which is getting overlooked in the debug version but as release version optimises memory allocations, its giving an access violation while releasing the inner component . Thinking of using purify for this problem, wht's ur suggesion .
thanks for ur response.
Best Regards,
Amey
|
|
|
|