atl

ATL how to Convert BSTR* str to registry key.SetValue(LPCTSTR str type

空扰寡人 提交于 2019-12-13 03:49:03
问题 It's been years since I have done C++ let alone ATL code I have this method that needs surgical help :( This is for a mobile app so I don't want to use CString and MFC I need to convert the BSTR* str to the correct type LPCTSTR for use in the registry Set.Value method STDMETHODIMP CAXSampleCtl::SendMSG(BSTR* str) { CRegKey key; key.Create(HKEY_LOCAL_MACHINE, _T("MyKeyName")); key.SetValue( str <<<--- nope, _T("MyValueName")); key.Flush(); key.Close(); return S_OK; } 回答1: COLE2T macro is just

Out-of-process COM singletons

跟風遠走 提交于 2019-12-13 00:06:35
问题 I am dealing with a single-threaded library (not thread safe) that I want to wrap in a COM out-of-process object to get around its thread non-safety. I need a behavior where each new COM object is instantiated in its own process - some form of out-of-process singleton. It's been a while since I've been dealing with hardcore COM so I am not sure how to approach this or whether this is at all possible without some trickery. 回答1: Call CoRegisterClassObject() with the REGCLS argument set to

How do I create interface methods using .tlb types in VS C++?

北城余情 提交于 2019-12-12 21:17:35
问题 Background: The .TLB file contains interfaces written in language 'X'. I don't have .h, .idl, .tlh, or any other header files - just the .TLB file. Language 'X' does not export compatible .h, .idl, etc. I use the VS wizard to add an ATL simple object to my ATL project. I want to add a method to the interface of my simple ATL object that uses one of the .TLB defined types for a parameter. // Something like the following in the .idl file: interface ISomeInterface : IUnknown { HRESULT SomeMethod

Parse JSON ISO8601 date in C++/CX

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-12 16:36:04
问题 I have a date string coming from JSON "2012-08-01T15:42:06Z" and want to parse that in Windows Runtime. As far as I know, only COleDateTime is available to handle this. I can only get it to correctly parse the string when I take out the 'T' & 'Z' characters, but that adds an extra parsing step on my end. WORKS: COleDateTime dateTime; dateTime.ParseDateTime(L"2012-08-01 15:42:06", 0UL, 1033UL); FAILS: COleDateTime dateTime; dateTime.ParseDateTime(L"2012-08-01T15:42:06Z", 0UL, 1033UL); Anyone

CA2W gave me a “'AtlThrowLastWin32': identifier not found” error

流过昼夜 提交于 2019-12-12 12:18:34
问题 I got a strange compilation error when I followed the MSDN document to use CA2W to convert big5 strings to unicode strings in Visual Studio 2005. This is the code I wrote: #include <string> #include <atldef.h> #include <atlconv.h> using namespace std; int _tmain(int argc, _TCHAR* argv[]) { string chineseInBig5 = "\xA4\xA4\xA4\xE5"; ATL::CA2W(chineseInBig5.c_str()); return 0; } The compilation error: error C3861: 'AtlThrowLastWin32': identifier not found I don't know how this could happen. The

What requirements are necessary and sufficient for an ActiveX control to be used directly on an Excel worksheet?

浪尽此生 提交于 2019-12-12 10:49:32
问题 The Microsoft Office support article "Add or register an ActiveX control" says: IMPORTANT: Not all ActiveX controls can be used directly on worksheets; some can be used only on Microsoft Visual Basic for Applications (VBA) UserForms. When you work with these controls, Excel displays the message Cannot insert object if you try to add them to a worksheet. However, I cannot find documented anywhere the requirements that are necessary and sufficient for a control to be used directly on a

How do I get the HWND for an ActiveX control after the control has been initialised/activated?

巧了我就是萌 提交于 2019-12-12 10:09:52
问题 I am creating an ATL 8.0 based ActiveX control in C++ using Visual Studio 2008. I need to create a sub-window and attach it to the ActiveX control. How do I get access to the HWND that is owned by the ActiveX control? Which ATL function can I override in order to use the HWND after the control's window has been created? 回答1: ActiveX would allow you to define your own methods on your own interface (to address Brians assumption), but that likely won't help here. The ActiveX control might very

How to create a splitter in ATL/WTL?

青春壹個敷衍的年華 提交于 2019-12-12 09:59:14
问题 I want to place the elements of my (resizable) dialog in one of two panes. How do I create a splitter for the panes, using WTL? I found CSplitterImpl and CSplitterWindowImpl , but I can't figure out how to use them with my dialogs. 回答1: WTLExplorer sample from WTL should get you the idea, see \Samples\WTLExplorer. If you'd like more, there's a lot around, e.g. http://www.viksoe.dk/code/splitterbar.htm 来源: https://stackoverflow.com/questions/7324153/how-to-create-a-splitter-in-atl-wtl

How to write simple background thread in CWorkerThread

微笑、不失礼 提交于 2019-12-12 09:02:00
问题 I'm trying to asynchronously run function in my add-on for Internet Explorer (I'm writing BHO in VC++). As suggested here I'm trying to use CWorkerThread. I've been trying to figure it out for hours but still have no idea how to do it. I don't have much experience in ATL. The lack of a good documentations or tutorials on Internet is killing me. I'm creating class by Add->Class and choosing ATL Simple Object (that's how you add classed to ATL project right?). But how to implement this

how does the .RGS file works

孤者浪人 提交于 2019-12-12 08:38:18
问题 In the .rgs file, there are some registry info, and I want to know how does the info in .rgs file added into regetry? I have a project AAA and it will generate the file AAA.DLL , and there is a file xxx.rgs which contains the registry info, and the AAA.DLL is built, then it will be deployed to another machine B, so I don't know how the registy info can be added on machine B, do I need register AAA.dll using regsvr32 command? 回答1: Usually your code calls CComModule::UpdateRegistryFromResource(