Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Visual Studio 2017 #1101

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions comtypes/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
This software is OSI Certified Open Source Software.
OSI Certified is a certification mark of the Open Source Initiative.

Copyright (c) 2006-2013, Thomas Heller.
Copyright (c) 2014, Comtypes Developers.
All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
1 change: 1 addition & 0 deletions comtypes/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include *.txt
31 changes: 31 additions & 0 deletions comtypes/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
comtypes
========

**comtypes** is a lightweight Python COM package, based on the ctypes_
FFI library, in less than 10000 lines of code (not counting the
tests).

**comtypes** allows to define, call, and implement custom and
dispatch-based COM interfaces in pure Python. It works on Windows,
64-bit Windows, and Windows CE.

Documentation:

https://pythonhosted.org/comtypes

Contribute using the `source repository and issue tracker
<https://github.com/enthought/comtypes/>`_ on GitHub.

Mailing list:

http://gmane.org/info.php?group=gmane.comp.python.comtypes.user

https://lists.sourceforge.net/lists/listinfo/comtypes-users/

Download:

Releases can be downloaded in the PyPI page:

https://pypi.python.org/pypi/comtypes

.. _ctypes: http://docs.python.org/lib/module-ctypes.html
101 changes: 101 additions & 0 deletions comtypes/comtypes/GUID.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
from ctypes import *
import sys

if sys.version_info >= (2, 6):
def binary(obj):
return bytes(obj)
else:
def binary(obj):
return buffer(obj)

BYTE = c_byte
WORD = c_ushort
DWORD = c_ulong

_ole32 = oledll.ole32

_StringFromCLSID = _ole32.StringFromCLSID
_CoTaskMemFree = windll.ole32.CoTaskMemFree
_ProgIDFromCLSID = _ole32.ProgIDFromCLSID
_CLSIDFromString = _ole32.CLSIDFromString
_CLSIDFromProgID = _ole32.CLSIDFromProgID
_CoCreateGuid = _ole32.CoCreateGuid

# Note: Comparing GUID instances by comparing their buffers
# is slightly faster than using ole32.IsEqualGUID.

class GUID(Structure):
_fields_ = [("Data1", DWORD),
("Data2", WORD),
("Data3", WORD),
("Data4", BYTE * 8)]

def __init__(self, name=None):
if name is not None:
_CLSIDFromString(unicode(name), byref(self))

def __repr__(self):
return u'GUID("%s")' % unicode(self)

def __unicode__(self):
p = c_wchar_p()
_StringFromCLSID(byref(self), byref(p))
result = p.value
_CoTaskMemFree(p)
return result
__str__ = __unicode__

def __cmp__(self, other):
if isinstance(other, GUID):
return cmp(binary(self), binary(other))
return -1

def __nonzero__(self):
return self != GUID_null

def __eq__(self, other):
return isinstance(other, GUID) and \
binary(self) == binary(other)

def __hash__(self):
# We make GUID instances hashable, although they are mutable.
return hash(binary(self))

def copy(self):
return GUID(unicode(self))

def from_progid(cls, progid):
"""Get guid from progid, ...
"""
if hasattr(progid, "_reg_clsid_"):
progid = progid._reg_clsid_
if isinstance(progid, cls):
return progid
elif isinstance(progid, basestring):
if progid.startswith("{"):
return cls(progid)
inst = cls()
_CLSIDFromProgID(unicode(progid), byref(inst))
return inst
else:
raise TypeError("Cannot construct guid from %r" % progid)
from_progid = classmethod(from_progid)

def as_progid(self):
"Convert a GUID into a progid"
progid = c_wchar_p()
_ProgIDFromCLSID(byref(self), byref(progid))
result = progid.value
_CoTaskMemFree(progid)
return result

def create_new(cls):
"Create a brand new guid"
guid = cls()
_CoCreateGuid(byref(guid))
return guid
create_new = classmethod(create_new)

GUID_null = GUID()

__all__ = ["GUID"]
Loading