|
Isn't it recommended to call CoInitializeEx(). I have had problems with CoInitialise() before and changing to ...Ex may help.
Dave.
|
|
|
|
|
Did you freed all the interface references?
E.g. YourInterface->Release(), or if you are using smart pointers, setting them to NULL?
I have seen a crash before when I forgot to free all the references before I called CoUninitialize().
Hope it helps,
Sunny
|
|
|
|
|
Hi,
I have stumbled across a problem again, and this time, it is on retrieving an element from a SAFEARRAY. The following code shows what I am trying to achieve:
// Creates a user
IUser* pUser4 = NULL;
CoCreateInstance( __uuidof( User ), NULL, CLSCTX_INPROC_SERVER,
IID_IUser, (void**)&pUser4 );
// Store my first name into it
pUser4->put_FirstName( L"Sunny" );
// Creates a variant that contains an array of type IUnknown pointers
_variant_t* userArray = new _variant_t;
userArray->vt = VT_ARRAY | VT_UNKNOWN;
// Create the array
SAFEARRAY* pSA;
SAFEARRAYBOUND bounds = { 1, 0 };
pSA = SafeArrayCreate( VT_UNKNOWN, 1, &bounds );
// Turn my pUser4 pointer into the IUnknown pointer
IUnknown* pUnk = NULL;
pUser4->QueryInterface( IID_IUnknown, (void**)&pUnk );
// put the IUnknown pointer into the array, and store the array
// into the variant
long a = 0;
SafeArrayPutElement( pSA, &a, pUnk );
userArray->parray = pSA;
// Retrieve the element
SAFEARRAY* ans = userArray->parray;
IUnknown* pUnk2 = NULL;
SafeArrayGetElement( ans, &a, pUnk2 ); // problem occurs
IUser* pUser5 = NULL;
pUnk2->QueryInterface( IID_IUser, (void**)&pUser5 );
BSTR first;
pUser5->get_FirstName( &first );
//======================== END
The problem arises when I tried to get the IUnknown pointer from the array by calling SafeArrayGetElement. I looked at the debugger, and it showed that the address of pUnk2 is 0x00000000.
I am wondering if anybody known what I have done wrong?
Help is apprepriated
Sunny
|
|
|
|
|
I'm not sure the problem is that but I know if you want to access the buffer of SAFEARRAY ,after you create it you have to use SafeArrayAccessData() method,and after you finished working with it you have to
use SafeArrayUnAccessData() .
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
Hi,
I'm using ::OleCreate to activate an Excel worksheet (Excel.Sheet) in-place in an MDI child window. The problem is I want to control the out-of-process server instance (Excel.Application) that is instancing the worksheets.
The default Windows behviour seems to either create the Excel.Sheet instances from whichever server was launched first, or just creates a new server if no server is activated.
Does anyone know of a way of specifying which server the out-of-process object is created in?
Many thanks in advance.
|
|
|
|
|
Hi !
I'm building an App using Visual Basic 6, where I would like to display many ActiveX controls.
The number and types of ActiveX to display is not hard-coded in the App, but rather put in a text file that would be read during initialization of the App, thus allowing me to add/remove ActiveX controls without recompiling my App.
My problem is I don't know how to use an ActiveX control in VB without registering it (Project->Component) and putting it into a form. I would like to register it during code execution and placing it into my form dynamically.
Anyone knows how to do that ?
Thank you for your help !
Jerome
|
|
|
|
|
Jerome C wrote:
I would like to register it during code execution and placing it into my form dynamically
First , normally, you must always register the COM object.
Second you're are talking perhaps about late binding ...
So you can declare something like this:
dim x as object
'read file, retrieve the progid of the class
set x = CoGetObject("",progid)
or
'read the name of class to instancing
set x = CreateObject("myClass.xpto")
If you want really to register you must deal with reg* api , like RegSaveKey or RegSetValue ..., for instance placing all the registries entries on the text file per object and using the registry keys to save the values ..., or writing a reg file for each object and call the ShellExecute api to automatically merge the .reg file, and so on ... you get the idea ...
Cheers,
Joao Vaz
|
|
|
|
|
What does that error (STG_E_MEDIUMFULL) mean?
The message is 'Not enough storage is available to complete this operation.' still it has nothing in common at all with the real problem. What can cause such a message and how to fix it up?
The code is (error-handling omitted):
StgCreateDocfile(L"Image.bmp", STGM_CREATE | STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 0, &pStorage);
pStorage->CreateStream(L"Image.bmp", STGM_CREATE | STGM_READWRITE | STGM_SHARE_EXCLUSIVE, NULL, NULL, &pStream);
Image->QueryInterface(IID_IPersistStream, (void**)&pPersistStream);
OleSaveToStream(pPersistStream, pStream);
* Origin: Silence Must Be Heard (2:5030/744.235)
|
|
|
|
|
Can I control the IE browser by using a COM?
is there a example?
thanks!
|
|
|
|
|
Check MSDN / Platform SDK / Web development / Internet SDK / Reusing browser technology.
|
|
|
|
|
Yes,
From memory you need to connect to "InternetExplorer.Application". Check out the OLE/COM viewwer and it will show you all the methods/property you can access.
Dave.
|
|
|
|
|
Thank you for your help!
I want get the data that IE browser send to the server before the sending action is executed,encrypt the data,and then give the crypto-data to the browser for sending to the server!
Could you give me some advice about that!
|
|
|
|
|
wabc wrote:
I want get the data that IE browser send to the server before the sending action is executed,encrypt the data,and then give the crypto-data to the browser for sending to the server!
I've never tried it, but.....
You could try and trap the BeforeNavigate2 event. When you get this, call the Stop method, encrypt your data and then call the Navigate2 method.
As I say, I've never tried this, but it looks OK....
Dave.
|
|
|
|
|
I have o develop a netmeeting application
which only has to send and reciev files nothing else
please help as running short on time and very new to com
take care
pauli
|
|
|
|
|
You can use the samples from NetMeeting SDK ( as far as I remember they have one about file transfer using NetMeeting).
|
|
|
|
|
Hi friends,
I have some email messages saved in a database, I'd like to have an option
to preview the selected message like the way Outlook Express is doing, you
can read the message, see pictures. I believe IE is being used in this aspect,
can anybody provide me some hints on how to achieve this? thanks.
Frank
|
|
|
|
|
Anonymous wrote:
I have some email messages saved in a database, I'd like to have an option
to preview the selected message like the way Outlook Express is doing, you
can read the message, see pictures. I believe IE is being used in this aspect,
can anybody provide me some hints on how to achieve this? thanks.
Seems like Outlook Express extracts the HTML text and images from the raw email message source and then, yes, uses MSHTML (which is the IE HTML-viewing and editing engine) to display it in the preview pane.
So, you may do it in two ways I think: 1) Extract all the data (the HTML-source and the MIMEd images or so) to pass them to a CHtmlView instance or 2) use some native Outlook automation objects, browse its object model to explore.
Or, if it's OK to preview in a separate window, you can just write the message to a file and then run it;)
(H) Serge
* Origin: Silence Must Be Heard (2:5030/844.235)
|
|
|
|
|
Hi all,
I have a question on multiple import. The following describe my scenerio:
I have first created a dll, which contains a COM object with the following idl:
interface A : public IUnknown
{
HRESULT MethodA();
};
Later, I have created a second dll, which contains a COM object that make use of the first dll. Therefore, in the second dll's idl file, I did the following:
import A.dll
interface B : public IUnknown
{
HRESULT MethodB( [in] A* foo );
};
The problem comes when I wrote a client to test out both servers.
Since my client needs to create A to pass it to the method in B, I need to include both dlls in my client file:
#import A.dll;
#import B.dll;
void main()
{
// first create A
// then create B
// next, pass A into B
}
The problem arises when I tried to compile the client program. I got a redefinition of A. Does anybody know what I should do?
Thanks,
Sunny
|
|
|
|
|
Sunny, Have you tried only to import b.dll ?
When you are importing B , you're importing A implicitly , so I think that you only need the #import B.dll.
Cheers,
Joao Vaz
|
|
|
|
|
Hi,
all
I have written a ActiveX control ,and I used it in another
application. And now I want to build the .ocx file ,but there are some errors .Detail message as follows:
LINK : fatal error LNK1168: cannot open Debug/MfcActiveX.ocx for writing
who can tell me why?
Regards.
|
|
|
|
|
Thats because one time before one application,for example when visual studio compile it does not release it after compile and register it.If you restart your computer may be it works.(or you test it in ActiveX Test container and did not close it)
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
I am attempting to use the MSCEGrid.dll control for WinCE (Pocket PC 2002).
After a little information gathering, I discovered I needed to create an IDL file, create a type library and create the header files.
I did this. I even changed one of the datatypes from "single" to float.
Now when I include my newly created header file (mscegrid.h), I get the following errors:
error C2501: 'MIDL_INTERFACE' : missing storage-class or type specifiers
error C2440: 'initializing' : cannot convert from 'char [37]' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
...
yada yada yada...
Anyone know how to fix this?
|
|
|
|
|
|
I'm a little confused... What and where would I use the #import directive? The problem that I was running into was that MIDL_INTERFACE was not defined anywhere. When I looked at
#include "rpcndr.h"
in VS 6.0 it contained this
#define MIDL_INTERFACE(x) struct __declspec(uuid(x)) __declspec(novtable)
however in WinCE 300 SDK it did not. To fix this, I just defined MIDL_INTERFACE in my IDL generated header file.
However, I can't imagine this is what I should really be doing just to add a control to my WinCE application.
|
|
|
|
|
Who has used the regexp object in system32\vbscipt.dll to parse the text string. I have tried it and make it work!
But i don't know why i can get only one match(that is the matches.GetCount()==1), even there are many exist. The next is my code:
void CInetSessionDlg::ParsePage(CString szPattern, CString szContent){ //m_regExp's declaration is on other place link this: IRegExp m_regExp; //The class IMatchCollection and IMatch are both got from the tlb //m_regExp = regExp; try{ if(m_regExp.CreateDispatch(__uuidof(RegExp)) == FALSE) { AfxMessageBox("CreateDispatch Failed!"); return; } //IMatchCollection2 * temp; m_regExp.SetIgnoreCase(TRUE); m_regExp.SetPattern(LPCTSTR(szPattern)); if(m_regExp.Test(LPCSTR(szContent))) { //IMatchCollection2 matches=m_regExp.Execute(szContent); ISubMatches matches = m_regExp.Execute(szContent); for(long i = 0; i < matches.GetCount(); i++) { IMatch2 match = matches.GetItem(i); //IMatch2 match = temp->GetItem(i); CString strLink = match.GetValue(); m_cbHref.AddString(strLink); } } } catch(_com_error& e) { AfxMessageBox("Com Error occurred!" + e.Description()); return; }}
in this implementation file's header file:
i defined the RegExp(copied from the file RegExp.tlh got from vbscript.dll)
struct __declspec(uuid("3f4daca4-160d-11d2-a8e9-00104b365c9f"))RegExp; // [ default ] interface IRegExp2
Why? Who can tell me how to use vbscript.dll in VC++ 6.0
thanks a lot!
Sincerely, Davidlou
davidlou68@hotmail.com
|
|
|
|
|