From waseem.afser at gmail.com Sat Apr 11 09:32:09 2020 From: waseem.afser at gmail.com (Waseem Afser) Date: Sat, 11 Apr 2020 19:02:09 +0530 Subject: [python-win32] User login details when running a service Message-ID: Is there any possible method to get the logged in user's username from a windows service ? FYI: getpass.getuser() and other similar methods return the computer name instead of the username of the user when the script runs as a service. -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Sat Apr 11 14:09:20 2020 From: timr at probo.com (Tim Roberts) Date: Sat, 11 Apr 2020 11:09:20 -0700 Subject: [python-win32] User login details when running a service In-Reply-To: References: Message-ID: On Apr 11, 2020, at 6:32 AM, Waseem Afser wrote: > > Is there any possible method to get the logged in user's username from a windows service ? Your assumption that there is only one "logged in user? is false, which is why the information you seek is not readily available. There is a WMI query that can return the name of all logged in users: https://stackoverflow.com/questions/5218778/how-do-i-get-the-currently-logged-username-from-a-windows-service-in-net ? Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 3279 bytes Desc: not available URL: From waseem.afser at gmail.com Sat Apr 11 15:16:12 2020 From: waseem.afser at gmail.com (Waseem Afser) Date: Sun, 12 Apr 2020 00:46:12 +0530 Subject: [python-win32] User login details when running a service In-Reply-To: References: Message-ID: I was kind of blank when I started off with the link you provided but with some searching i got into a post which got Queries and i used it this way : objWMIService = win32com.client.Dispatch("WbemScripting.SWbemLocator") strComputer = "." objSWbemServices = objWMIService.ConnectServer(strComputer, "root\cimv2") oos = objSWbemServices.ExecQuery("SELECT UserName FROM Win32_ComputerSystem") oo = oos[0] # list all object properties for op in oo.Properties_: username = op.Value while debugging it, i got \ but when i installed the service and started it it kept crashing and the reason behind it was : (-2147221008, 'CoInitialize has not been called.', None, None) i have no idea whether i did it correctly, please guide me if it's wrong ! Thank you a lot ! On Sat, Apr 11, 2020 at 11:49 PM Tim Roberts wrote: > On Apr 11, 2020, at 6:32 AM, Waseem Afser wrote: > > > Is there any possible method to get the logged in user's username from a > windows service ? > > > Your assumption that there is only one "logged in user? is false, which is > why the information you seek is not readily available. > > There is a WMI query that can return the name of all logged in users: > > > https://stackoverflow.com/questions/5218778/how-do-i-get-the-currently-logged-username-from-a-windows-service-in-net > ? > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > https://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From waseem.afser at gmail.com Sat Apr 11 15:34:22 2020 From: waseem.afser at gmail.com (Waseem Afser) Date: Sun, 12 Apr 2020 01:04:22 +0530 Subject: [python-win32] OPEN GL error when starting a Kivy App from a service Message-ID: I'm trying to start a Kivy App bundled using Pyinstaller from a windows service made using win32serviceutil.ServiceFramework and the open GL version it finds / gets over there is 1.1 I have a GTX 1060 with Open GL verison 4.6. When i run the Kivy App normally ( not from a service ) everything is fine. But when it starts from a service as mentioned above this is the result .... ______________________________________ [INFO ] [Window ] Provider: sdl2 [INFO ] [GL ] Using the "OpenGL" graphics system [INFO ] [GL ] GLEW initialization succeeded [INFO ] [GL ] No framebuffers extension is supported [INFO ] [GL ] Backend used [INFO ] [GL ] OpenGL version [INFO ] [GL ] OpenGL vendor [INFO ] [GL ] OpenGL renderer [INFO ] [GL ] OpenGL parsed version: 1, 1 [CRITICAL] [GL ] Minimum required OpenGL version (2.0) NOT found! OpenGL version detected: 1.1 Version: b'1.1.0' Vendor: b'Microsoft Corporation' Renderer: b'GDI Generic' Try upgrading your graphics drivers and/or your graphics hardware in case of problems. ________________________________________ FYI if i run it normally the output would be : _________________________________________ [INFO ] [Window ] Provider: sdl2 [INFO ] [GL ] Using the "OpenGL" graphics system [INFO ] [GL ] GLEW initialization succeeded [INFO ] [GL ] Backend used [INFO ] [GL ] OpenGL version [INFO ] [GL ] OpenGL vendor [INFO ] [GL ] OpenGL renderer [INFO ] [GL ] OpenGL parsed version: 4, 6 [INFO ] [GL ] Shading version [INFO ] [GL ] Texture max size <32768> [INFO ] [GL ] Texture max units <32> __________________________________________ I've been nagging behind this issue for days ! with even developers from Kivy being confused ! Thanks a lot in advance ! -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- [INFO ] [Logger ] Record log in C:\Windows\system32\config\systemprofile\.kivy\logs\kivy_20-04-12_0.txt [INFO ] [Kivy ] v1.11.1 [INFO ] [Kivy ] Installed at "D:\PythonVENV\mist-app\dist\app\kivy\__init__.pyc" [INFO ] [Python ] v3.7.7 (tags/v3.7.7:d7c567b08f, Mar 10 2020, 10:41:24) [MSC v.1900 64 bit (AMD64)] [INFO ] [Python ] Interpreter at "D:\PythonVENV\mist-app\dist\app\app.exe" [INFO ] [Factory ] 184 symbols loaded [INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored) [INFO ] [Window ] Provider: sdl2 [INFO ] [GL ] Using the "OpenGL" graphics system [INFO ] [GL ] GLEW initialization succeeded [INFO ] [GL ] No framebuffers extension is supported [INFO ] [GL ] Backend used [INFO ] [GL ] OpenGL version [INFO ] [GL ] OpenGL vendor [INFO ] [GL ] OpenGL renderer [INFO ] [GL ] OpenGL parsed version: 1, 1 [CRITICAL] [GL ] Minimum required OpenGL version (2.0) NOT found! OpenGL version detected: 1.1 Version: b'1.1.0' Vendor: b'Microsoft Corporation' Renderer: b'GDI Generic' Try upgrading your graphics drivers and/or your graphics hardware in case of problems. The application will leave now. [INFO ] [Logger ] Record log in C:\Windows\system32\config\systemprofile\.kivy\logs\kivy_20-04-12_1.txt [INFO ] [Kivy ] v1.11.1 [INFO ] [Kivy ] Installed at "D:\PythonVENV\mist-app\dist\app\kivy\__init__.pyc" [INFO ] [Python ] v3.7.7 (tags/v3.7.7:d7c567b08f, Mar 10 2020, 10:41:24) [MSC v.1900 64 bit (AMD64)] [INFO ] [Python ] Interpreter at "D:\PythonVENV\mist-app\dist\app\app.exe" [INFO ] [Factory ] 184 symbols loaded [INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored) [INFO ] [Window ] Provider: sdl2 [INFO ] [GL ] Using the "OpenGL" graphics system [INFO ] [GL ] GLEW initialization succeeded [INFO ] [GL ] No framebuffers extension is supported [INFO ] [GL ] Backend used [INFO ] [GL ] OpenGL version [INFO ] [GL ] OpenGL vendor [INFO ] [GL ] OpenGL renderer [INFO ] [GL ] OpenGL parsed version: 1, 1 [CRITICAL] [GL ] Minimum required OpenGL version (2.0) NOT found! OpenGL version detected: 1.1 Version: b'1.1.0' Vendor: b'Microsoft Corporation' Renderer: b'GDI Generic' Try upgrading your graphics drivers and/or your graphics hardware in case of problems. The application will leave now. [INFO ] [Logger ] Record log in C:\Windows\system32\config\systemprofile\.kivy\logs\kivy_20-04-12_2.txt [INFO ] [Kivy ] v1.11.1 [INFO ] [Kivy ] Installed at "D:\PythonVENV\mist-app\dist\app\kivy\__init__.pyc" [INFO ] [Python ] v3.7.7 (tags/v3.7.7:d7c567b08f, Mar 10 2020, 10:41:24) [MSC v.1900 64 bit (AMD64)] [INFO ] [Python ] Interpreter at "D:\PythonVENV\mist-app\dist\app\app.exe" [INFO ] [Factory ] 184 symbols loaded [INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored) [INFO ] [Window ] Provider: sdl2 [INFO ] [GL ] Using the "OpenGL" graphics system [INFO ] [GL ] GLEW initialization succeeded [INFO ] [GL ] No framebuffers extension is supported [INFO ] [GL ] Backend used [INFO ] [GL ] OpenGL version [INFO ] [GL ] OpenGL vendor [INFO ] [GL ] OpenGL renderer [INFO ] [GL ] OpenGL parsed version: 1, 1 [CRITICAL] [GL ] Minimum required OpenGL version (2.0) NOT found! OpenGL version detected: 1.1 Version: b'1.1.0' Vendor: b'Microsoft Corporation' Renderer: b'GDI Generic' Try upgrading your graphics drivers and/or your graphics hardware in case of problems. The application will leave now. [INFO ] [Logger ] Record log in C:\Windows\system32\config\systemprofile\.kivy\logs\kivy_20-04-12_3.txt [INFO ] [Kivy ] v1.11.1 [INFO ] [Kivy ] Installed at "D:\PythonVENV\mist-app\dist\app\kivy\__init__.pyc" [INFO ] [Python ] v3.7.7 (tags/v3.7.7:d7c567b08f, Mar 10 2020, 10:41:24) [MSC v.1900 64 bit (AMD64)] [INFO ] [Python ] Interpreter at "D:\PythonVENV\mist-app\dist\app\app.exe" [INFO ] [Factory ] 184 symbols loaded [INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored) [INFO ] [Window ] Provider: sdl2 [INFO ] [GL ] Using the "OpenGL" graphics system [INFO ] [GL ] GLEW initialization succeeded [INFO ] [GL ] No framebuffers extension is supported [INFO ] [GL ] Backend used [INFO ] [GL ] OpenGL version [INFO ] [GL ] OpenGL vendor [INFO ] [GL ] OpenGL renderer [INFO ] [GL ] OpenGL parsed version: 1, 1 [CRITICAL] [GL ] Minimum required OpenGL version (2.0) NOT found! OpenGL version detected: 1.1 Version: b'1.1.0' Vendor: b'Microsoft Corporation' Renderer: b'GDI Generic' Try upgrading your graphics drivers and/or your graphics hardware in case of problems. The application will leave now. [INFO ] [Logger ] Record log in C:\Windows\system32\config\systemprofile\.kivy\logs\kivy_20-04-12_4.txt [INFO ] [Kivy ] v1.11.1 [INFO ] [Kivy ] Installed at "D:\PythonVENV\mist-app\dist\app\kivy\__init__.pyc" [INFO ] [Python ] v3.7.7 (tags/v3.7.7:d7c567b08f, Mar 10 2020, 10:41:24) [MSC v.1900 64 bit (AMD64)] [INFO ] [Python ] Interpreter at "D:\PythonVENV\mist-app\dist\app\app.exe" [INFO ] [Factory ] 184 symbols loaded [INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored) [INFO ] [Window ] Provider: sdl2 [INFO ] [GL ] Using the "OpenGL" graphics system [INFO ] [GL ] GLEW initialization succeeded [INFO ] [GL ] No framebuffers extension is supported [INFO ] [GL ] Backend used [INFO ] [GL ] OpenGL version [INFO ] [GL ] OpenGL vendor [INFO ] [GL ] OpenGL renderer [INFO ] [GL ] OpenGL parsed version: 1, 1 [CRITICAL] [GL ] Minimum required OpenGL version (2.0) NOT found! OpenGL version detected: 1.1 Version: b'1.1.0' Vendor: b'Microsoft Corporation' Renderer: b'GDI Generic' Try upgrading your graphics drivers and/or your graphics hardware in case of problems. The application will leave now. [INFO ] [Logger ] Record log in C:\Windows\system32\config\systemprofile\.kivy\logs\kivy_20-04-12_5.txt [INFO ] [Kivy ] v1.11.1 [INFO ] [Kivy ] Installed at "D:\PythonVENV\mist-app\dist\app\kivy\__init__.pyc" [INFO ] [Python ] v3.7.7 (tags/v3.7.7:d7c567b08f, Mar 10 2020, 10:41:24) [MSC v.1900 64 bit (AMD64)] [INFO ] [Python ] Interpreter at "D:\PythonVENV\mist-app\dist\app\app.exe" [INFO ] [Factory ] 184 symbols loaded [INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored) [INFO ] [Window ] Provider: sdl2 [INFO ] [GL ] Using the "OpenGL" graphics system [INFO ] [GL ] GLEW initialization succeeded [INFO ] [GL ] No framebuffers extension is supported [INFO ] [GL ] Backend used [INFO ] [GL ] OpenGL version [INFO ] [GL ] OpenGL vendor [INFO ] [GL ] OpenGL renderer [INFO ] [GL ] OpenGL parsed version: 1, 1 [CRITICAL] [GL ] Minimum required OpenGL version (2.0) NOT found! OpenGL version detected: 1.1 Version: b'1.1.0' Vendor: b'Microsoft Corporation' Renderer: b'GDI Generic' Try upgrading your graphics drivers and/or your graphics hardware in case of problems. The application will leave now. From lenikur at gmail.com Tue Apr 14 21:56:38 2020 From: lenikur at gmail.com (Nikita Lepetukhin) Date: Wed, 15 Apr 2020 04:56:38 +0300 Subject: [python-win32] (no subject) Message-ID: Hello! I use win32com module and everything is ok but I cannot find the way how to pass VT_DECIMAL variant value to COM object's method. There is a COM interface: interface IProperty : IDispatch { ... [propget, id(DISPID_VALUE)] HRESULT Value([out, retval] VARIANT* pVal); [propput, id(DISPID_VALUE)] HRESULT Value([in] VARIANT new_value); ... } This is how the interface is described in gencache: class IProperty(DispatchBaseClass): CLSID = IID('{0A4C05A0-107B-4A8B-9E34-44ED9B117A25}') coclass_clsid = IID('{2171DCF1-B70B-4CAB-9EB7-F7FED71956B4}') _prop_map_get_ = { "Value": (0, 2, (12, 0), (), "Value", None), } _prop_map_put_ = { "Value": ((0, LCID, 4, 0),()), } ... In python code I get the object by the following way: comObj = win32com.client.Dispatch("XXX.XXX.4") prop = comObj.Property # prop is IProperty The problem is here: prop.Value = 0.123456 I need to pass here VT_DECIMAL variant (due to data precision requirements) but it comes to COM object implementation as VT_R8 variant. I tried to use decimal python type but it comes as VT_CY variant. Could you help me to find out how to pass VT_DECIMAL variant from python to COM? I would appreciate your help very much! Regards, Nikita Lepetukhin -------------- next part -------------- An HTML attachment was scrubbed... URL: From lenikur at gmail.com Tue Apr 14 22:09:03 2020 From: lenikur at gmail.com (Nikita Lepetukhin) Date: Wed, 15 Apr 2020 05:09:03 +0300 Subject: [python-win32] VT_DECIMAL variant In-Reply-To: References: Message-ID: Hello! I use win32com module and everything is ok but I cannot find the way how to pass VT_DECIMAL variant value to COM object's method. There is a COM interface: interface IProperty : IDispatch { ... [propget, id(DISPID_VALUE)] HRESULT Value([out, retval] VARIANT* pVal); [propput, id(DISPID_VALUE)] HRESULT Value([in] VARIANT new_value); ... } This is how the interface is described in gencache: class IProperty(DispatchBaseClass): CLSID = IID('{0A4C05A0-107B-4A8B-9E34-44ED9B117A25}') coclass_clsid = IID('{2171DCF1-B70B-4CAB-9EB7-F7FED71956B4}') _prop_map_get_ = { "Value": (0, 2, (12, 0), (), "Value", None), } _prop_map_put_ = { "Value": ((0, LCID, 4, 0),()), } ... In python code I get the object by the following way: comObj = win32com.client.Dispatch("XXX.XXX.4") prop = comObj.Property # prop is IProperty The problem is here: prop.Value = 0.123456 I need to pass here VT_DECIMAL variant (due to data precision requirements) but it comes to COM object implementation as VT_R8 variant. I tried to use decimal python type but it comes as VT_CY variant. Could you help me to find out how to pass VT_DECIMAL variant from python to COM? I would appreciate your help very much! Regards, Nikita Lepetukhin -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Wed Apr 15 02:03:16 2020 From: timr at probo.com (Tim Roberts) Date: Tue, 14 Apr 2020 23:03:16 -0700 Subject: [python-win32] VT_DECIMAL variant In-Reply-To: References: Message-ID: <95CC13F4-905E-44B0-92A4-9780D5E8B787@probo.com> > On Apr 14, 2020, at 7:09 PM, Nikita Lepetukhin wrote: > > I use win32com module and everything is ok but I cannot find the way how to pass VT_DECIMAL variant value to COM object's method. > ... > This is how the interface is described in gencache: > class IProperty(DispatchBaseClass): > CLSID = IID('{0A4C05A0-107B-4A8B-9E34-44ED9B117A25}') > coclass_clsid = IID('{2171DCF1-B70B-4CAB-9EB7-F7FED71956B4}') > > _prop_map_get_ = { > "Value": (0, 2, (12, 0), (), "Value", None), > } That?s a property that returns a VT_VARIANT. > In python code I get the object by the following way: > ... > I need to pass here VT_DECIMAL variant (due to data precision requirements) but it comes to COM object implementation as VT_R8 variant. > I tried to use decimal python type but it comes as VT_CY variant. > > Could you help me to find out how to pass VT_DECIMAL variant from python to COM? > I would appreciate your help very much! The VT_CY type, the Python decimal type, and the C# decimal type are all the same ? a 128-point fixed point value with 92 bits of precision. That?s probably what you should use. In order to use VT_DECIMAL, then you probably can?t use automatic translation. ? Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. -------------- next part -------------- An HTML attachment was scrubbed... URL: From lenikur at gmail.com Wed Apr 15 05:13:00 2020 From: lenikur at gmail.com (Nikita Lepetukhin) Date: Wed, 15 Apr 2020 12:13:00 +0300 Subject: [python-win32] VT_DECIMAL variant In-Reply-To: <95CC13F4-905E-44B0-92A4-9780D5E8B787@probo.com> References: <95CC13F4-905E-44B0-92A4-9780D5E8B787@probo.com> Message-ID: Tim, thanks for replying! VT_CY number doesn?t fit the precision I need (16 digits to the right of the decimal point). It has only 4 digits according to this description: https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-oaut/5a2b34c4-d109-438e-9ec8-84816d8de40d The decimal (VT_DECIMAL) has precision up to 28 places ( https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-oaut/b5493025-e447-4109-93a8-ac29c48d018d ). It is exactly the same as python decimal has. They match to each other exactly and much better than VT_CY and python decimal. So maybe it wasn?t the best solution to automatically convert python decimal to VT_CY variant. Whatever.. what?s done is done. As I understand there is another way (?manual?) to make the property set call. Could you show how to make it? Nikita Lepetukhin ??, 15 ???. 2020 ?. ? 09:03, Tim Roberts : > > > On Apr 14, 2020, at 7:09 PM, Nikita Lepetukhin wrote: > > I use win32com module and everything is ok but I cannot find the way how > to pass VT_DECIMAL variant value to COM object's method. > ... > This is how the interface is described in gencache: > class IProperty(DispatchBaseClass): > CLSID = IID('{0A4C05A0-107B-4A8B-9E34-44ED9B117A25}') > coclass_clsid = IID('{2171DCF1-B70B-4CAB-9EB7-F7FED71956B4}') > > _prop_map_get_ = { > "Value": (0, 2, (12, 0), (), "Value", None), > } > > > That?s a property that returns a VT_VARIANT. > > > In python code I get the object by the following way: > ... > I need to pass here VT_DECIMAL variant (due to data precision > requirements) but it comes to COM object implementation as VT_R8 variant. > I tried to use decimal python type but it comes as VT_CY variant. > > Could you help me to find out how to pass VT_DECIMAL variant from python > to COM? > I would appreciate your help very much! > > > The VT_CY type, the Python decimal type, and the C# decimal type are all > the same ? a 128-point fixed point value with 92 bits of precision. That?s > probably what you should use. In order to use VT_DECIMAL, then you > probably can?t use automatic translation. > ? > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > https://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lenikur at gmail.com Wed Apr 15 05:47:41 2020 From: lenikur at gmail.com (Nikita Lepetukhin) Date: Wed, 15 Apr 2020 12:47:41 +0300 Subject: [python-win32] VT_DECIMAL variant In-Reply-To: References: <95CC13F4-905E-44B0-92A4-9780D5E8B787@probo.com> Message-ID: Tim, thanks for replying! VT_CY number doesn?t fit the precision I need (16 digits to the right of the decimal point). It has only 4 digits according to this description: https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-oaut/5a2b34c4-d109-438e-9ec8-84816d8de40d The decimal (VT_DECIMAL) has precision up to 28 places ( https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-oaut/b5493025-e447-4109-93a8-ac29c48d018d ). It is exactly the same as python decimal has. They match to each other exactly and much better than VT_CY and python decimal. So maybe it wasn?t the best solution to automatically convert python decimal to VT_CY variant. Whatever.. what?s done is done. As I understand there is another way (?manual?) to make the property set call. Could you show how to make it? Nikita Lepetukhin ??, 15 ???. 2020 ?. ? 09:03, Tim Roberts : > > > On Apr 14, 2020, at 7:09 PM, Nikita Lepetukhin wrote: > > I use win32com module and everything is ok but I cannot find the way how > to pass VT_DECIMAL variant value to COM object's method. > ... > This is how the interface is described in gencache: > class IProperty(DispatchBaseClass): > CLSID = IID('{0A4C05A0-107B-4A8B-9E34-44ED9B117A25}') > coclass_clsid = IID('{2171DCF1-B70B-4CAB-9EB7-F7FED71956B4}') > > _prop_map_get_ = { > "Value": (0, 2, (12, 0), (), "Value", None), > } > > > That?s a property that returns a VT_VARIANT. > > > In python code I get the object by the following way: > ... > I need to pass here VT_DECIMAL variant (due to data precision > requirements) but it comes to COM object implementation as VT_R8 variant. > I tried to use decimal python type but it comes as VT_CY variant. > > Could you help me to find out how to pass VT_DECIMAL variant from python > to COM? > I would appreciate your help very much! > > > The VT_CY type, the Python decimal type, and the C# decimal type are all > the same ? a 128-point fixed point value with 92 bits of precision. That?s > probably what you should use. In order to use VT_DECIMAL, then you > probably can?t use automatic translation. > ? > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > https://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Wed Apr 15 14:05:16 2020 From: timr at probo.com (Tim Roberts) Date: Wed, 15 Apr 2020 11:05:16 -0700 Subject: [python-win32] VT_DECIMAL variant In-Reply-To: References: <95CC13F4-905E-44B0-92A4-9780D5E8B787@probo.com> Message-ID: <85e88ac3-c6fb-c16f-c258-b54067542e72@probo.com> Nikita Lepetukhin wrote: > > Tim, thanks for replying! > > > VT_CY number doesn?t fit the precision I need (16 digits to the right > of the decimal point). It has only 4 digits according to this description: > > https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-oaut/5a2b34c4-d109-438e-9ec8-84816d8de40d > > > The decimal (VT_DECIMAL) has precision up to 28 places > (https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-oaut/b5493025-e447-4109-93a8-ac29c48d018d > ). > It is exactly the same as python decimal has. They match to each other > exactly and much better than VT_CY and python decimal. So maybe it > wasn?t the best solution to automatically convert python decimal to > VT_CY variant. Whatever.. what?s done is done. > It's possible this is a misunderstanding in the pythoncom code. CURRENCY goes back to the days of Visual Basic 6, whereas DECIMAL is much more recent.? It may be appropriate to file a bug report. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 3389 bytes Desc: S/MIME Cryptographic Signature URL: From timr at probo.com Wed Apr 15 15:08:56 2020 From: timr at probo.com (Tim Roberts) Date: Wed, 15 Apr 2020 12:08:56 -0700 Subject: [python-win32] VT_DECIMAL variant In-Reply-To: References: <95CC13F4-905E-44B0-92A4-9780D5E8B787@probo.com> <85e88ac3-c6fb-c16f-c258-b54067542e72@probo.com> Message-ID: <602434d6-f6bb-d650-b026-328c6431764c@probo.com> Nikita Lepetukhin wrote: > ok, I will report a bug. But to be honest I'm trying to find the > solution. > Do I understand right that currently there is no way to pass > VT_DECIMAL variant from python to com? Oh, it is possible; the library does many automatic conversions, but it's possible to do it by hand.? I just don't know the recipe.? If Tim Golden is listening, perhaps he can point us to a reference. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 3389 bytes Desc: S/MIME Cryptographic Signature URL: From lenikur at gmail.com Wed Apr 15 14:21:44 2020 From: lenikur at gmail.com (Nikita Lepetukhin) Date: Wed, 15 Apr 2020 21:21:44 +0300 Subject: [python-win32] VT_DECIMAL variant In-Reply-To: <85e88ac3-c6fb-c16f-c258-b54067542e72@probo.com> References: <95CC13F4-905E-44B0-92A4-9780D5E8B787@probo.com> <85e88ac3-c6fb-c16f-c258-b54067542e72@probo.com> Message-ID: ok, I will report a bug. But to be honest I'm trying to find the solution. Do I understand right that currently there is no way to pass VT_DECIMAL variant from python to com? On Wed, Apr 15, 2020 at 9:05 PM Tim Roberts wrote: > Nikita Lepetukhin wrote: > > > > Tim, thanks for replying! > > > > > > VT_CY number doesn?t fit the precision I need (16 digits to the right > > of the decimal point). It has only 4 digits according to this > description: > > > > > https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-oaut/5a2b34c4-d109-438e-9ec8-84816d8de40d > > > > > > The decimal (VT_DECIMAL) has precision up to 28 places > > ( > https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-oaut/b5493025-e447-4109-93a8-ac29c48d018d > > < > https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-oaut/b5493025-e447-4109-93a8-ac29c48d018d>). > > > It is exactly the same as python decimal has. They match to each other > > exactly and much better than VT_CY and python decimal. So maybe it > > wasn?t the best solution to automatically convert python decimal to > > VT_CY variant. Whatever.. what?s done is done. > > > It's possible this is a misunderstanding in the pythoncom code. CURRENCY > goes back to the days of Visual Basic 6, whereas DECIMAL is much more > recent. It may be appropriate to file a bug report. > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > https://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lenikur at gmail.com Wed Apr 15 15:16:55 2020 From: lenikur at gmail.com (Nikita Lepetukhin) Date: Wed, 15 Apr 2020 22:16:55 +0300 Subject: [python-win32] VT_DECIMAL variant In-Reply-To: <602434d6-f6bb-d650-b026-328c6431764c@probo.com> References: <95CC13F4-905E-44B0-92A4-9780D5E8B787@probo.com> <85e88ac3-c6fb-c16f-c258-b54067542e72@probo.com> <602434d6-f6bb-d650-b026-328c6431764c@probo.com> Message-ID: Thanks Tim! Now I have a hope )) Could I reach Tim Golden somehow? On Wed, Apr 15, 2020 at 10:09 PM Tim Roberts wrote: > Nikita Lepetukhin wrote: > > ok, I will report a bug. But to be honest I'm trying to find the > > solution. > > Do I understand right that currently there is no way to pass > > VT_DECIMAL variant from python to com? > > Oh, it is possible; the library does many automatic conversions, but > it's possible to do it by hand. I just don't know the recipe. If Tim > Golden is listening, perhaps he can point us to a reference. > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > https://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From coderx7 at gmail.com Tue Apr 21 03:25:30 2020 From: coderx7 at gmail.com (Hossein Hasanpour) Date: Tue, 21 Apr 2020 11:55:30 +0430 Subject: [python-win32] Pywin32 latest documentation Message-ID: Hello everyone, Is there any kind of updated documentation concerning Pywin32? The only online documentation that I know of is http://timgolden.me.uk/pywin32-docs which is the online version of the Pywin32.chm located in the site-packages. It is old and it doesn't have anything regarding the new modules for example. It be greatly appreciated if we could have some kind of documentation that reflect the latest changes in the library. Thanks a lot in advance, Seyyed Hossein -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Wed Apr 22 01:50:41 2020 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 22 Apr 2020 06:50:41 +0100 Subject: [python-win32] Pywin32 latest documentation In-Reply-To: References: Message-ID: Well I've just updated those docs from the latest release TJG On 21/04/2020 08:25, Hossein Hasanpour wrote: > Hello everyone, > Is there any kind of updated documentation concerning Pywin32? > The only online documentation that I know of is > http://timgolden.me.uk/pywin32-docs which is the online version of the > Pywin32.chm located in the site-packages. It is old and it doesn't > have anything regarding the new modules for example. > It be greatly appreciated if we could have some kind of documentation > that reflect the latest changes in the library. > > Thanks a lot in advance, > Seyyed Hossein > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > https://mail.python.org/mailman/listinfo/python-win32 -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Wed Apr 22 06:05:59 2020 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 22 Apr 2020 11:05:59 +0100 Subject: [python-win32] Pywin32 latest documentation In-Reply-To: References: Message-ID: <8fad8290-afd3-ed12-c10a-122ae2a8f601@timgolden.me.uk> All my code does is to take the .chm file which ships with pywin32, unpick it, and turn it into a series of HTML pages. There's a tiny bit of tidying-up but that's all. So if there are no docs in that Help file for some modules, there won't be any on those web pages. If they *are* there and I'm somehow skipping them, please let me know and I'll try to fix the problem. Or see if you can spot the problem and fix it yourself: ? https://github.com/tjguk/pywin32-docs If your question is: why aren't there any docs for those modules at all? Then the answer will be: because no-one's written any. I would think that a PR for the repo would probably be welcome: ? https://github.com/mhammond/pywin32 TJG On 22/04/2020 10:13, Hossein Hasanpour wrote: > Hi, > Thanks a lot, but why aren't there any information concerning the > python modules there? > I mean, I can't find any entry for win32serviceutils > module > for example! > In fact, none of the modules in the /*Lib > */directory(https://github.com/mhammond/pywin32/tree/master/win32/Lib) > seem to be exposed in the documentation! > -------------- next part -------------- An HTML attachment was scrubbed... URL: From terry.y.davis at gmail.com Wed Apr 22 12:28:10 2020 From: terry.y.davis at gmail.com (Terry Davis) Date: Wed, 22 Apr 2020 09:28:10 -0700 Subject: [python-win32] [win32com] Meaning of "TypeError: Only com_record objects can be used as records"? In-Reply-To: References: Message-ID: Any ideas? On Tue, Jan 28, 2020 at 1:06 PM Terry Davis wrote: > Update 2: After discovering the `pythoncom.GetRecordFromGuids` and > `.GetRecordFromTypeInfo` (with the comment: "This function will fail if the > specified type info does not have a guid defined"). > > I found that the Record types don't appear to have a GUID. > lib_pyITypelib.GetDocumentation(4) = ('SoftwareInfo', None, 0, None) > lib_pyITypelib.GetTypeInfo(4).GetTypeAttr().iid > = IID('{00000000-0000-0000-0000-000000000000}') > > So, is it possible to create a Record object without a GUID? > (Assuming that passing a Record object `ccs.GetSoftwareInfo(info= Record Object>)` is the correct approach here.) > > I also tried assigning a `pythoncom.CreateGuid() to the `iid` attribute > above, but `GetRecordFromGuids` failed with `pywintypes.com_error: > (-2147319765, 'Element not found.', None, None)`. So I assume the GUID > assignment didn't make it outside of python into COM-space. > > P.S. > I also found this old thread: > > https://grokbase.com/t/python/python-win32/0821b2n4e5/how-to-create-a-com-record > which appears to be related to my problem, but no solutions were > identified. > (I tried the `DumbDispatch` solution; it didn't work). > > > On Mon, Jan 27, 2020 at 4:31 PM Terry Davis > wrote: > >> Update: The functions that don't work return Record types, and the ones >> that do work just return multiple values (a tuple). >> Do I need to pass in the appropriate Record type (or an empty record) >> during each function call? >> If so, how do I get to the Record types that I see in the python object >> browser (python -m win32com.client.combrowse)? >> >> Thanks, >> Terry >> >> On Mon, Jan 27, 2020 at 3:33 PM Terry Davis >> wrote: >> >>> Hi all, >>> >>> I tried searching the mailing list archives for "com_record" but didn't >>> find anything relevant. >>> >>> For context, I'm trying to access a COM interface defined in a .tlb file. >>> >>> Here's a skeleton of the script I'm using to expose this interface: >>> import pythoncom >>> from win32com.client import gencache >>> >>> lib_GUID = "{}" >>> lib_major = 1 >>> lib_minor = 0 >>> lib_pyITypelib = pythoncom.LoadRegTypeLib(lib_GUID, lib_major, lib_minor) >>> lib = gencache.EnsureModuleForTypelibInterface(_lib_pyITypelib) >>> >>> ccs = lib.CControlServer() # CControlServer is a CoClass >>> eid, *other = ccs.LoadExperiment(**path to file**) # Works >>> ccs.GetSoftwareInfo() # Fails with exception below. >>> ccs.GetSolvent(eid) # also fails >>> >>> I can't dig down in the debugger to find the source of the exception, so >>> I'm hoping someone here can help! >>> >>> >>> Exception: >>> >>> def GetSoftwareInfo(self, info=pythoncom.Missing): >>> >>> >>> in >>> ----> 1 ccs.GetSoftwareInfo() >>> >>> ~\AppData\Local\Temp\gen_py\3.7\x0x1x0.py in GetSoftwareInfo(self, >>> info) >>> 279 def GetSoftwareInfo(self, info=pythoncom.Missing): >>> 280 'method GetSoftwareInfo' >>> --> 281 return self._ApplyTypes_(13, 1, (24, 0), ((36, >>> 2),), 'GetSoftwareInfo', None,info >>> 282 ) >>> 283 >>> >>> C:\Python37\lib\site-packages\win32com\client\__init__.py in >>> _ApplyTypes_(self, dispid, wFlags, retType, argTypes, user, resultCLSID, >>> *args) >>> 465 def _ApplyTypes_(self, dispid, wFlags, retType, >>> argTypes, user, resultCLSID, *args): >>> 466 return self._get_good_object_( >>> --> 467 self._oleobj_.InvokeTypes(dispid, 0, >>> wFlags, retType, argTypes, *args), >>> 468 user, resultCLSID) >>> 469 >>> >>> TypeError: Only com_record objects can be used as records >>> >> -------------- next part -------------- An HTML attachment was scrubbed... URL: From pavel.olifer at gmail.com Thu Apr 23 01:10:58 2020 From: pavel.olifer at gmail.com (Pavel Olifer) Date: Thu, 23 Apr 2020 08:10:58 +0300 Subject: [python-win32] How to change print copies Message-ID: Good day! i use your package for changing printer settings (duplex, copies). for duplex it is work, but for copies it doesn't. @source_code def set_duplex(printer_name): # print_defaults = {"DesiredAccess": win32print.PRINTER_ACCESS_ADMINISTER} print_defaults = {"DesiredAccess": win32print.PRINTER_ACCESS_USE} handle = win32print.OpenPrinter(printer_name, print_defaults) level = 2 attributes = win32print.GetPrinter(handle, level) print('Printer= ', printer_name) print('Copies= ', win32print.GetPrinter(handle, level)['pDevMode'].Copies) print('Duplex= ', win32print.GetPrinter(handle, level)['pDevMode'].Duplex) # attributes['pDevMode'].Duplex = 1 # no flip attributes['pDevMode'].Duplex = 2 # flip up # attributes['pDevMode'].Duplex = 3 # flip over attributes['pDevMode'].Copies = 4 #for key in attributes: # print('{}'.format(key)) #for n in dir(attributes['DevMode']): # print('{} {}'.format(n, getattr(attributes['DevMode'], n))) try: print('try') win32print.SetPrinter(handle, level, attributes, 0) print('Copies= ', win32print.GetPrinter(handle, level)['pDevMode'].Copies) print('Duplex= ', win32print.GetPrinter(handle, level)['pDevMode'].Duplex) except Exception as e: print(e) win32print.ClosePrinter(handle) def print_excel(printer_no, path_to_file, duplex='Y', copies=4): printer_name = app_config.PRINTER_NAMES[printer_no] if duplex == 'Y': set_duplex(printer_name=printer_name) win32api.ShellExecute( 1, 'printto', path_to_file, '{}'.format(printer_name), '.', 0 ) if __name__ == '__main__': set_duplex(printer_name='\\\\server_name\\printer_name') if i change and then check (just print) properties changed and document printed on both sides, but only 1 copy, not 4. may be you know what did i miss ? My question on stackoverflow: https://stackoverflow.com/questions/58415047/python-win32print-how-to-change-copies -- Pavel -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Fri Apr 24 01:06:20 2020 From: timr at probo.com (Tim Roberts) Date: Thu, 23 Apr 2020 22:06:20 -0700 Subject: [python-win32] How to change print copies In-Reply-To: References: Message-ID: <638D5144-F5A6-43A9-B56C-7CD4E799FD2C@probo.com> On Apr 22, 2020, at 10:10 PM, Pavel Olifer wrote: > > i use your package for changing printer settings (duplex, copies). > for duplex it is work, but for copies it doesn?t. Some Windows printers don?t honor the ?Copies? selection directly. The application has to generate multiple copies on its own. Have you seen a multi-copy setting work using the native driver? ? Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From pavel.olifer at gmail.com Fri Apr 24 01:35:09 2020 From: pavel.olifer at gmail.com (Pavel Olifer) Date: Fri, 24 Apr 2020 08:35:09 +0300 Subject: [python-win32] How to change print copies In-Reply-To: <638D5144-F5A6-43A9-B56C-7CD4E799FD2C@probo.com> References: <638D5144-F5A6-43A9-B56C-7CD4E799FD2C@probo.com> Message-ID: Dear Tim, "Have you seen a multi-copy setting work using the native driver?" - i didn't catch this sentence... did you mean did i use native driver in python code? All MFP on my job only Konika-Minolta devices. -- pavel On Fri, Apr 24, 2020 at 8:11 AM Tim Roberts wrote: > On Apr 22, 2020, at 10:10 PM, Pavel Olifer wrote: > > > > i use your package for changing printer settings (duplex, copies). > > for duplex it is work, but for copies it doesn?t. > > Some Windows printers don?t honor the ?Copies? selection directly. The > application has to generate multiple copies on its own. Have you seen a > multi-copy setting work using the native driver? > ? > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > https://mail.python.org/mailman/listinfo/python-win32 > -- -- po +7 (977) 004 67 53 -------------- next part -------------- An HTML attachment was scrubbed... URL: From pavel.olifer at gmail.com Fri Apr 24 06:00:07 2020 From: pavel.olifer at gmail.com (Pavel Olifer) Date: Fri, 24 Apr 2020 13:00:07 +0300 Subject: [python-win32] How to change print copies In-Reply-To: References: <638D5144-F5A6-43A9-B56C-7CD4E799FD2C@probo.com> Message-ID: and some interesting things that if i change copies using this attributes['pDevMode'].Copies = 4 and than print('Copies= ', win32print.GetPrinter(handle, level)['pDevMode'].Copies) i see 4 qty. but if i print using win32api.ShellExecute( 1, 'printto', path_to_file, '{}'.format(printer_name), '.', 0 ) printer printed only 1 copy. --po On Fri, Apr 24, 2020 at 8:35 AM Pavel Olifer wrote: > Dear Tim, > "Have you seen a multi-copy setting work using the native driver?" - i > didn't catch this sentence... did you mean did i use native driver in > python code? > All MFP on my job only Konika-Minolta devices. > -- pavel > > > On Fri, Apr 24, 2020 at 8:11 AM Tim Roberts wrote: > >> On Apr 22, 2020, at 10:10 PM, Pavel Olifer >> wrote: >> > >> > i use your package for changing printer settings (duplex, copies). >> > for duplex it is work, but for copies it doesn?t. >> >> Some Windows printers don?t honor the ?Copies? selection directly. The >> application has to generate multiple copies on its own. Have you seen a >> multi-copy setting work using the native driver? >> ? >> Tim Roberts, timr at probo.com >> Providenza & Boekelheide, Inc. >> >> _______________________________________________ >> python-win32 mailing list >> python-win32 at python.org >> https://mail.python.org/mailman/listinfo/python-win32 >> > > > -- > -- po > +7 (977) 004 67 53 > -- -- po +7 (977) 004 67 53 -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Mon Apr 27 06:29:59 2020 From: mail at timgolden.me.uk (Tim Golden) Date: Mon, 27 Apr 2020 11:29:59 +0100 Subject: [python-win32] Pywin32 latest documentation In-Reply-To: References: Message-ID: <31463414-06ed-c794-dce5-71ca2d894d5e@timgolden.me.uk> Just a quick follow-up to say that I'd spotted a couple of bugs in the code which generates the website copy, so I think that what's now showing contains everything in the CHM file. Feel free to ping me if you spot anything missing: http://timgolden.me.uk/pywin32-docs/ TJG On 22/04/2020 06:50, Tim Golden wrote: > > Well I've just updated those docs from the latest release > > TJG > > On 21/04/2020 08:25, Hossein Hasanpour wrote: >> Hello everyone, >> Is there any kind of updated documentation concerning Pywin32? >> The only online documentation that I know of is >> http://timgolden.me.uk/pywin32-docs which is the online version of >> the Pywin32.chm located in the site-packages. It is old and it >> doesn't have anything regarding the new modules for example. >> It be greatly appreciated if we could have some kind of documentation >> that reflect the latest changes in the library. >> >> Thanks a lot in advance, >> Seyyed Hossein >> >> _______________________________________________ >> python-win32 mailing list >> python-win32 at python.org >> https://mail.python.org/mailman/listinfo/python-win32 -------------- next part -------------- An HTML attachment was scrubbed... URL: From terry.y.davis at gmail.com Mon Apr 27 15:58:43 2020 From: terry.y.davis at gmail.com (Terry Davis) Date: Mon, 27 Apr 2020 12:58:43 -0700 Subject: [python-win32] [win32com] Meaning of "TypeError: Only com_record objects can be used as records"? In-Reply-To: References: Message-ID: I just discovered this message: https://mail.python.org/pipermail/python-list/2003-August/214888.html and when I tried getting a com_record: client.Record("SoftwareInfo",app._com) I got this error: ValueError: The structure 'SoftwareInfo' is not defined in module 'x1x0' I looked in the generated file, and its RecordMap dict was empty, with a comment. There are a dozen or so structs that should be available to the interface. Is there any workaround for this, such as manually defining each com_record? RecordMap = { ###'LegacyMicroSamplerInfo': '{00000000-0000-0000-0000-000000000000}', # Record disabled because it doesn't have a non-null GUID } I was also given an idl file, which includes record definitions, like this one: typedef struct SoftwareInfo { BSTR name; BSTR version; } SoftwareInfo; Is there something missing from the idl file that's causing these to be missed by win32com? On Wed, Apr 22, 2020 at 9:28 AM Terry Davis wrote: > Any ideas? > > On Tue, Jan 28, 2020 at 1:06 PM Terry Davis > wrote: > >> Update 2: After discovering the `pythoncom.GetRecordFromGuids` and >> `.GetRecordFromTypeInfo` (with the comment: "This function will fail if the >> specified type info does not have a guid defined"). >> >> I found that the Record types don't appear to have a GUID. >> lib_pyITypelib.GetDocumentation(4) = ('SoftwareInfo', None, 0, None) >> lib_pyITypelib.GetTypeInfo(4).GetTypeAttr().iid >> = IID('{00000000-0000-0000-0000-000000000000}') >> >> So, is it possible to create a Record object without a GUID? >> (Assuming that passing a Record object `ccs.GetSoftwareInfo(info=> Record Object>)` is the correct approach here.) >> >> I also tried assigning a `pythoncom.CreateGuid() to the `iid` attribute >> above, but `GetRecordFromGuids` failed with `pywintypes.com_error: >> (-2147319765, 'Element not found.', None, None)`. So I assume the GUID >> assignment didn't make it outside of python into COM-space. >> >> P.S. >> I also found this old thread: >> >> https://grokbase.com/t/python/python-win32/0821b2n4e5/how-to-create-a-com-record >> which appears to be related to my problem, but no solutions were >> identified. >> (I tried the `DumbDispatch` solution; it didn't work). >> >> >> On Mon, Jan 27, 2020 at 4:31 PM Terry Davis >> wrote: >> >>> Update: The functions that don't work return Record types, and the ones >>> that do work just return multiple values (a tuple). >>> Do I need to pass in the appropriate Record type (or an empty record) >>> during each function call? >>> If so, how do I get to the Record types that I see in the python object >>> browser (python -m win32com.client.combrowse)? >>> >>> Thanks, >>> Terry >>> >>> On Mon, Jan 27, 2020 at 3:33 PM Terry Davis >>> wrote: >>> >>>> Hi all, >>>> >>>> I tried searching the mailing list archives for "com_record" but didn't >>>> find anything relevant. >>>> >>>> For context, I'm trying to access a COM interface defined in a .tlb >>>> file. >>>> >>>> Here's a skeleton of the script I'm using to expose this interface: >>>> import pythoncom >>>> from win32com.client import gencache >>>> >>>> lib_GUID = "{}" >>>> lib_major = 1 >>>> lib_minor = 0 >>>> lib_pyITypelib = pythoncom.LoadRegTypeLib(lib_GUID, lib_major, >>>> lib_minor) >>>> lib = gencache.EnsureModuleForTypelibInterface(_lib_pyITypelib) >>>> >>>> ccs = lib.CControlServer() # CControlServer is a CoClass >>>> eid, *other = ccs.LoadExperiment(**path to file**) # Works >>>> ccs.GetSoftwareInfo() # Fails with exception below. >>>> ccs.GetSolvent(eid) # also fails >>>> >>>> I can't dig down in the debugger to find the source of the exception, >>>> so I'm hoping someone here can help! >>>> >>>> >>>> Exception: >>>> >>>> def GetSoftwareInfo(self, info=pythoncom.Missing): >>>> >>>> >>>> in >>>> ----> 1 ccs.GetSoftwareInfo() >>>> >>>> ~\AppData\Local\Temp\gen_py\3.7\x0x1x0.py in >>>> GetSoftwareInfo(self, info) >>>> 279 def GetSoftwareInfo(self, info=pythoncom.Missing): >>>> 280 'method GetSoftwareInfo' >>>> --> 281 return self._ApplyTypes_(13, 1, (24, 0), ((36, >>>> 2),), 'GetSoftwareInfo', None,info >>>> 282 ) >>>> 283 >>>> >>>> C:\Python37\lib\site-packages\win32com\client\__init__.py in >>>> _ApplyTypes_(self, dispid, wFlags, retType, argTypes, user, resultCLSID, >>>> *args) >>>> 465 def _ApplyTypes_(self, dispid, wFlags, retType, >>>> argTypes, user, resultCLSID, *args): >>>> 466 return self._get_good_object_( >>>> --> 467 self._oleobj_.InvokeTypes(dispid, 0, >>>> wFlags, retType, argTypes, *args), >>>> 468 user, resultCLSID) >>>> 469 >>>> >>>> TypeError: Only com_record objects can be used as records >>>> >>> -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Tue Apr 28 02:31:32 2020 From: timr at probo.com (Tim Roberts) Date: Mon, 27 Apr 2020 23:31:32 -0700 Subject: [python-win32] [win32com] Meaning of "TypeError: Only com_record objects can be used as records"? In-Reply-To: References: Message-ID: On Apr 27, 2020, at 12:58 PM, Terry Davis wrote: > > I looked in the generated file, and its RecordMap dict was empty, with a comment. There are a dozen or so structs that should be available to the interface. Is there any workaround for this, such as manually defining each com_record? > > RecordMap = { > ###'LegacyMicroSamplerInfo': '{00000000-0000-0000-0000-000000000000}', # Record disabled because it doesn't have a non-null GUID > } > > I was also given an idl file, which includes record definitions, like this one: > > typedef struct SoftwareInfo { > BSTR name; > BSTR version; > } SoftwareInfo; > > Is there something missing from the idl file that's causing these to be missed by win32com? Well, yes. There are rigid rules for writing IDL to make a valid dispatch interface, and generic structs like that are not in those rules. Some people get the idea that anything they can express in C++ can be shoved in a COM interface, but it ain?t so. You should be able to add a GUID attribute to the IDL: [ uuid(12345678-1234-1234-1234-123456789ABC) ] typedef struct SoftwareInfo { ? } SoftwareInfo; Just generate a new GUID for each one. ? Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Thu Apr 30 22:45:34 2020 From: timr at probo.com (Tim Roberts) Date: Thu, 30 Apr 2020 19:45:34 -0700 Subject: [python-win32] [win32com] Meaning of "TypeError: Only com_record objects can be used as records"? In-Reply-To: References: Message-ID: <7034E286-13E4-497A-BEEE-0B3FC6746481@probo.com> On Apr 30, 2020, at 11:47 AM, Terry Davis wrote: > > Thanks for the pointer! I'll let the maintainers of this software know. > > Do you know if applying this fix is sufficient for win32com to successfully handle returned structs? I don?t know. That was the fix suggested by the old mailing list threads I found. ? Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From joaopedrosp at gmail.com Thu Apr 30 12:10:21 2020 From: joaopedrosp at gmail.com (=?UTF-8?Q?Jo=C3=A3o_Pereira?=) Date: Thu, 30 Apr 2020 17:10:21 +0100 Subject: [python-win32] INotificationActivationCallback interface in python-pywin32 Message-ID: Looking through the respond to toast activations page, amongst other requirements, an implementation of the INotificationActivationCallback interface is required. However, after searching the repo for the structures identified in the sample code nothing yielded. Did I miss something or does the wrapper not support this yet? Thank you, Jo?o Pereira -------------- next part -------------- An HTML attachment was scrubbed... URL: From terry.y.davis at gmail.com Thu Apr 30 14:47:59 2020 From: terry.y.davis at gmail.com (Terry Davis) Date: Thu, 30 Apr 2020 11:47:59 -0700 Subject: [python-win32] [win32com] Meaning of "TypeError: Only com_record objects can be used as records"? In-Reply-To: References: Message-ID: Hi Tim, Thanks for the pointer! I'll let the maintainers of this software know. Do you know if applying this fix is sufficient for win32com to successfully handle returned structs? -Terry On Mon, Apr 27, 2020 at 11:32 PM Tim Roberts wrote: > > On Apr 27, 2020, at 12:58 PM, Terry Davis wrote: > > > > I looked in the generated file, and its RecordMap dict was empty, with a > comment. There are a dozen or so structs that should be available to the > interface. Is there any workaround for this, such as manually defining each > com_record? > > > > RecordMap = { > > ###'LegacyMicroSamplerInfo': '{00000000-0000-0000-0000-000000000000}', # > Record disabled because it doesn't have a non-null GUID > > } > > > > I was also given an idl file, which includes record definitions, like > this one: > > > > typedef struct SoftwareInfo { > > BSTR name; > > BSTR version; > > } SoftwareInfo; > > > > Is there something missing from the idl file that's causing these to be > missed by win32com? > > Well, yes. There are rigid rules for writing IDL to make a valid dispatch > interface, and generic structs like that are not in those rules. Some > people get the idea that anything they can express in C++ can be shoved in > a COM interface, but it ain?t so. > > You should be able to add a GUID attribute to the IDL: > > [ uuid(12345678-1234-1234-1234-123456789ABC) ] > typedef struct SoftwareInfo { > ? > } SoftwareInfo; > > Just generate a new GUID for each one. > ? > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > https://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: