atl

Write a unicode CString to a file using WriteFile API

[亡魂溺海] 提交于 2020-01-01 19:34:49
问题 How can I write contents of a CString instance to a file opened by CreateFile using WriteFile Win32 API function? Please note MFC is not used, and CString is used by including "atlstr.h" edit: Can just I do WriteFile(handle, cstr, cstr.GetLength(), &dwWritten, NULL); or WriteFile(handle, cstr, cstr.GetLength() * sizeof(TCHAR), &dwWritten, NULL); ? 回答1: With ATL it's like this: CString sValue; CStringW sValueW(sValue); // NOTE: CT2CW() can be used instead CAtlFile File; ATLENSURE_SUCCEEDED

Firing a COM Event From Another Thread

主宰稳场 提交于 2020-01-01 07:06:27
问题 I have created an in-process COM object (DLL) using ATL. Note that this is an object and not a control (so has no window or user-interface.) My problem is that I am trying to fire an event from a second thread and I am getting a 'Catastrophic failure' (0x8000FFFF). If I fire the event from my main thread, then I don't get the error. The second thread is calling CoInitializeEx but this makes no difference. I am using the Apartment threading model but switching to Free Threaded doesn't help.

How can I convert a JavaScript array() to an ATL/COM array?

匆匆过客 提交于 2019-12-29 08:08:08
问题 How can I convert a JavaScript array() to an ATL/COM array without using VBArray? What I want to convert is a new Array() to a SAFEARRAY. 回答1: Here's a code to do just that (considering you already got the JS Array object as a C++ Variant), same way as Sheng Jiang suggested earlier: bool VariantToArray(__in const CComVariant& var, __out vector<CComVariant>& vecVars) { // convert variant to dispatch object CComPtr<IDispatch> pDispatch = VariantToDispatch(var); if (!pDispatch) return false; //

atlbase.h not found when using Visual C++ Express 2010

拈花ヽ惹草 提交于 2019-12-29 06:42:32
问题 So I tried moving my project to Visual C++ Express 2010 on Windows 7 from a previous version on Windows XP. I got all sorts of errors where atlbase.h was not found. This isn't so much a question but I wanted to document what my resolution was for others. Copied the following PlatformSDK files from my previous install and put them on my Windows 7 machine. PlatformSDK/include/atl PlatformSDK/include/mfc PlatformSDK/lib PlatformSDK/src/atl I then change the VC++ Directories in the project

ActiveX component cannot be created for COM component in release mode (VS2010 specific)

蓝咒 提交于 2019-12-25 06:31:30
问题 I have an ATL COM component(.exe) (VC++ ) in VS2008. Through VB6 client, i use CreateObject and get the object. But once the component is updated to VS2010 SP1, the VB6 client no longer is able to create the COM object. If I compile the VS2010 COM component in debug mode and get the .exe, VB6 client is working fine. In release mode, .exe is generated without any errors, and VB6 client fails saying ActiveX component cannot be created. Please help me in resloving this. 回答1: Finding out why COM

Child window for Internet explorer flickering

我们两清 提交于 2019-12-25 05:48:10
问题 I am writing a browser helper object and want to show a child window inside the internet explorer window to show the user some messages. I use DS_CONTROL and WS_CHILDWINDOW and want to get a behaviour similar to the message in this image: I succeeded in inserting and showing a child window, but the window is flickering and sometimes it's visible and sometimes the website content is above the window in the z coordinate. I tried to set the child window as topmost window, but that didn't change

How to get access of <iframe> body using c++/ATL/COM?

大兔子大兔子 提交于 2019-12-25 02:34:10
问题 I have written a browser helper object to get the text between the tags and use it for data mining purpose. I tried using it on igoogle (basically to test its capability on gadgets) and it failed in some of the cases where an <iframe> is present with some external source. I can get the <div> and its child <iframe> but fail to get the body. I get the frame collection from this API HRESULT IHTMLDocument2::get_frames(IHTMLFramesCollection2 **p); The problem can be re-created in igoogle and

What files do I need to distribute as an alternative to MS Visual C++ 2005 ATL merge modules?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-24 22:25:23
问题 Currently I'm distributing a software product that includes three merge modules: Microsoft_VC80_CRT_x86.msm ATL.msm policy_8_0_Microsoft_VC80_ATL_x86.msm Some customers use packaging technology that doesn't like these MSM files (I think because they have technical problems with them writing to WinSxS). Can I just distribute the dll files directly into my application's Program Files folder, and if so which dlls do I need? Is it just atl80.dll? 回答1: Your alternative is to run the VC_redist.exe

Marshalling a VARIANT back from COM to C++ client

谁说胖子不能爱 提交于 2019-12-24 18:59:18
问题 I'm attempting to marshal a safearray of BSTRs from a COM object, back to a C++ client application. My IDL definition of the function involved: [id(5), helpstring("method GetStreams")] HRESULT GetStreams( [out,retval] VARIANT* pvarStreamNames ); Here's my implementation of the GetStreams() function: STDMETHODIMP CArchiveManager::GetStreams(VARIANT* pvarStreamNames) { CComSafeArray<BSTR, VT_BSTR> saStreamNames; CComVariant varOutNames; Stream* pNext = NULL; int nNumStreams = m_Streams

How to configure ATL trace level and categories in VS2015

懵懂的女人 提交于 2019-12-24 16:20:02
问题 I want to trace the ATL registrar process in a project I'm building in VS2015 (community edition). In this post (third paragraph) it says that the ATL/MFC trace tool has been eliminated. Unfortunately the VS 2015 documentation does not reflect that change. It still talks about the trace tool (first paragraph under Remarks). My question is how do you specify that you want to see all messages related to the ATL registrar? 回答1: I studied the source code for ATL (which is installed as part of VS)