|
You might be able to get away with something like:
_Application WordApp;
_Document Doc;
LPDISPATCH pDisp;
LPUNKNOWN pUnk;
CLSID clsid;
::CLSIDFromProgID(L"Word.Application", &clsid);
if (::GetActiveObject(clsid, NULL, &pUnk) == S_OK)
{
VERIFY(pUnk->QueryInterface(IID_IDispatch, (void**) &pDisp) == S_OK);
WordApp.AttachDispatch(pDisp);
pUnk->Release();
Doc = WordApp.GetActiveDocument();
CString str = Doc.GetFullName();
}
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
I am writing a program that uses data structures such s std::vector and std::map and when I write a class that uses the structures and put the class in a dll, the compiler warns me against this saying the template classes cannot be exported.
Warning I recieved:
warning C4251: 'a' : class 'vector<int>' needs to have dll-interface to be used by clients of class 'MyClass'
a is a std::vector in my class MyClass
I get similar messages with std::map and the other data structures of the STL
Is there anyway around this problem because I do not want to write my own data structures but instead I want to use the STL.<code></code>
pplshero54 gives his most thanks
|
|
|
|
|
I am using Visual C++.NET
pplshero54 gives his most thanks
|
|
|
|
|
did you correctly said that std::vector<> had to be exported from the DLL with a mechanism such as __declspec( dllexport )
|
|
|
|
|
yes, I did all the correct __declspec stuff
pplshero54 gives his most thanks
|
|
|
|
|
How to acquired a pointer to Internet Explorer's IWebBrowser2 interface from IOleClientSite and IOleContainer?
Thanks
|
|
|
|
|
what do you need? IWebBrowser2 or IOleClientSite
|
|
|
|
|
Need to run this:
IOleCommandTarget* pCmdTarg;
CComPtr pWB;
CoCreateInstance(CLSID_WebBrowser, NULL, CLSCTX_INPROC, IID_IWebBrowser2, (void**)&pWB);
pWB->QueryInterface(IID_IOleCommandTarget, (void**)&pCmdTarg);
VARIANT vTemplatePath;
V_VT(&vTemplatePath) = VT_BSTR;
CComVariant vPTPath = argv[1];
pCmdTarg->Exec(&CGID_MSHTML, IDM_PRINTPREVIEW, NULL, &vPTPath, NULL);
But the pointer don't work.
|
|
|
|
|
if you change to CComPtr pWB to IWebBrowser2 pWB what happen?
|
|
|
|
|
Sorry! The code was this way: CComPtr <iwebbrowser2> pWB;
|
|
|
|
|
But CComPtr pWB; it was error unknown size
I think you need to CComPtr<ioleclientsite> pWB;
MSDN:
template< class T >class CComPtr
|
|
|
|
|
Sorry but I don't understand.
|
|
|
|
|
do you test //CComPtr<ioleclientsite> pWB;
|
|
|
|
|
I'm sorry to post this question here, but I'm a noob in C++. I'm a web programer(PHP, javascript, action script II), and I need very much of this.
I think the problem is the pointer. Why? I don't know, I just guess.
Thanks for your help!
|
|
|
|
|
I wanna capture the windowsNT logoff event.
WM_QUERYENDSESSION 'd help? and BTW can i trap this in
PreTranslateMessage() ??
I dont really like to keep logging off and On just to test this. your comments would be valuable
VuNic
|
|
|
|
|
You need to be looking out for WM_ENDSESSION , paying attention to the parameters of the message to tell if the user is logging off or not, or if a shutdown is being done.
Note that a well-known author wrote a few articles regarding problems with reliable detection of system shutdown and used something called the "Notepad test" to do it. Googling for that phrase may help.
You can also create a handler for the CTRL_LOGOFF_EVENT event (which may only be sent to console applications), which might work, too. A true Service will get shutdown notifications as well.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
thanks for the info james.
VuNic
|
|
|
|
|
Hi everyone,
I want to schedule a windows application(an IE window) to run at a fixed time and they system shud generate a message that the browser window is running and when if it shud close down due to any reason then also the system shud generate a message stating the browser has closed down.
Can any one please help me w/ a code or somthing ,i m having difficulty in using the schedule feature .
Thanking u
Regards,
Vikas
|
|
|
|
|
munsiyari wrote: Can any one please help me w/ a code or somthing ,i m having difficulty in using the schedule feature .
Look for the ITask and ITaskScheduler interfaces.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
Coinitialize();
ITaskScheduler *pIS;
CoCreateInstance(CLSID_CTaskScheduler,
NULL,
CLSCTX_INPROC_SERVER,
IID_ITaskScheduler,
(void **) &pIS);
IEnumWorkItems *pEnum;
pIS->Enum(&pEnum);
...
...
|
|
|
|
|
Thanx guys!! i really appreciate it.
|
|
|
|
|
I have a legacy MFC app that has recently been ported to VS 2005. Debug mode works fine, but release mode crashes on startup. I traced the code to a CImageList::Load method - which, in VS2005, now calls the following code:
AFX_ISOLATIONAWARE_FUNC(HIMAGELIST, ImageList_LoadImageW, (HINSTANCE hi,LPCWSTR lpbmp,int cx,int cGrow,COLORREF crMask,UINT uType,UINT uFlags), (hi,lpbmp,cx,cGrow,crMask,uType,uFlags),NULL)
This code is crashing (somewhere in the AFX_ISOLATIONAWARE_FUNC macro) and I have no ideas why. At first I thought the resource handle may be wrong, but if I call ImageList_LoadImageW directly, it works fine and returns a valid handle.
Anyone have any clues at all? There is no mention of this new macro anywhere I can find.
The Rob Blog Google Talk: robert.caldecott
|
|
|
|
|
This[^] could help you to some extent.
Nibu thomas
Software Developer
|
|
|
|
|
After much tweaking, I managed to fix the problem. The app in question was set to use 1-byte struct member alignment, which, for reasons only know to MS, caused these new macros to barf. I changed the setting to "Default" and used appropriate pragmas around the structs that needed 1-byte alignment, and the problem was cured!
The Rob Blog Google Talk: robert.caldecott
|
|
|
|
|
put here because I found this thread when I had a similar problem ...
We had a crash in one of the comdlg32 methods wrapped in a AFX_ISOLATIONAWARE_FUNC macro, the problem was eventually traced to some shonky code in MFC, namely CDllIsolationWrapperBase::GetModuleHandle()
This method uses ::GetModuleHandle to get to (in our case) comdlg32 IIF that module is already loaded - the primary distinction between ::GetModuleHandle and LoadLibrary is the upping of the refcount, done in the latter, not the former
Our scenario was (simplistically) as follows ...
1. our code loads a 1st party lib, this dll explicitly loads comdlg32
2. our code uses comdlg32 methods - first time through, MFC needs a handle, uses GetModuleHandle as described above
3. our code frees 1st party lib, in its shutdown, comdlg's refcount drops to 0, hence unloads comdlg
4. our code uses comdlg32 methods again - MFC has a handle, it has a procAddress, it calls it ... boom!
Obviously, this bug will exhibit similarly with all the libraries that use the MFC wrapper class
|
|
|
|