com

What's the difference between BSTR and _bstr_t?

前提是你 提交于 2019-12-18 10:53:05
问题 Can anyone explain the difference between the types mentioned above and some sample usage to clearly explain the difference between the two? Any help would be highly appreciated! Note: this question is a spin-off from this other question 回答1: BSTR is the string data type used with COM. _bstr_t is a wrapper class that works like a smart pointer, so it will free the allocated memory when the variable is destroyed or goes out of scope. _bstr_t also has reference counting, which increases every

Can't close Excel completely using win32com on Python

本秂侑毒 提交于 2019-12-18 10:35:48
问题 This is my code, and I found many answers for VBA, .NET framework and is pretty strange. When I execute this, Excel closes. from win32com.client import DispatchEx excel = DispatchEx('Excel.Application') wbs = excel.Workbooks wbs.Close() excel.Quit() wbs = None excel = None # <-- Excel Closes here But when I do the following, it does not close. excel = DispatchEx('Excel.Application') wbs = excel.Workbooks wb = wbs.Open('D:\\Xaguar\\A1.xlsm') wb.Close(False) wbs.Close() excel.Quit() wb = None

Check COM pointers for equality

谁说胖子不能爱 提交于 2019-12-18 08:57:51
问题 If I have two COM interface pointers (i.e. ID3D11Texture2D), and I want to check if they are the same underlying class instance, can I compare the two pointers directly for equality? I have seen code where we cast it to something else before the comparison is done, so wanted to confirm. BOOL IsEqual (ID3D11Texture2D *pTexture1, ID3D11Texture2D *pTexture2) { if (pTexture1 == pTexture2) { return true; } else { return false; } } Thanks. 回答1: The correct COM way to do this is to query interface

VSTO: manipulating COM objects (“one dot good, two dots bad”)

不问归期 提交于 2019-12-18 08:55:21
问题 Coming from an Excel VBA background I would frequently write code such as: Range("myRange").Offset(0, 1).Resize(1, ccData).EntireColumn.Delete I'm now moving to VSTO, and have been reading about RCW counters, etc., and the need to explicitly release COM objects. The basic advice seems to be: don't chain together references to Excel objects (as I have above) - hence "one dot good, two dots bad". My question is, am I correct that the above code is not the way to go in VSTO? If so, does that

Drag and drop large virtual files from C# to Windows Explorer

非 Y 不嫁゛ 提交于 2019-12-18 08:26:26
问题 I have a C# WPF application with a section that serves as an FTP client, listing files on a remote server and allowing the user to download them. I want the user to be able to drag and drop files from the file listing onto their own machine (i.e. into a Windows Explorer shell). To accomplish this, I used the VirtualFileDataObject code from Delay's blog, using the Action<Stream> overload of SetData . This works great on smaller files. My problem is: some of the files I'm dealing with are very

Return value from execScript(IHTMLWindow2)

浪子不回头ぞ 提交于 2019-12-18 08:25:57
问题 What is the best way to get the return value from IHTMLWindow2::execScript? I found this link, http://social.msdn.microsoft.com/Forums/en/ieextensiondevelopment/thread/712db8ec-0ceb-4efa-afe3-590dc6bbb7bf, I haven't tried this, is this the right way? Regards Manoj 回答1: Yes, that's how System.Windows.Forms.HtmlDocument.InvokeScript gets the return value. 回答2: Here's a good article that shows how to do this with C++. Next is my interpretation of it. Say, if your client-side JavaScript is:

Drag and drop large virtual files from C# to Windows Explorer

妖精的绣舞 提交于 2019-12-18 08:25:22
问题 I have a C# WPF application with a section that serves as an FTP client, listing files on a remote server and allowing the user to download them. I want the user to be able to drag and drop files from the file listing onto their own machine (i.e. into a Windows Explorer shell). To accomplish this, I used the VirtualFileDataObject code from Delay's blog, using the Action<Stream> overload of SetData . This works great on smaller files. My problem is: some of the files I'm dealing with are very

Python and Excel: Overwriting an existing file always prompts, despite XlSaveConflictResolution value

只谈情不闲聊 提交于 2019-12-18 08:20:46
问题 I'm using the Excel.Application COM object from a Python program to open a CSV file and save it as an Excel workbook. If the target file already exists, then I am prompted with this message: "A file named '...' already exists in this location. Do you want to replace it?" That message comes up despite the fact that I have set the XlSaveConflictResolution value to xlLocalSessionChanges, which is supposed to automatically overwrite the changes without prompting -- or so I thought. I'm using

How to do RegAsm so that it cover 32-bit and 64-bit?

有些话、适合烂在心里 提交于 2019-12-18 07:29:13
问题 I have a DLL file prepared by C# and my system is Windows 7 64-bit. When i apply the RegAsm its not adding the registry to 64-bit path but only adding it to 32-bit path. "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\RegAsm.exe" /register /codebase "C:\o.dll" then if i check my GUID in regedit.exe i see that i have it only in 32-bit registry path: HKEY_CLASSES_ROOT\CLSID\{... my guid is found here ....} instead of HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{... not found my guid ...} As a result i

How to convert 8209 array object variant to VT_VARIANT

╄→гoц情女王★ 提交于 2019-12-18 07:22:48
问题 I am calling a COM object method that returns an array variant object of type 8209 in my PHP code. $com_VArray = $com_Object->objectMethod; //Is a 8209 variant object I want in the end to pass the converted VT_VARIANT object as a value for another COM object method which requires its input to be VT_VARIANT[12]. I am converting $com_VArray to a VT_VARIANT object variant type by issuing the following $obj_VT_VARIANT = variant_cast($com_VArray, VT_VARIANT); But then I get this following error