Python3+pywin32 getting a user-defined ODBC data source _php tutorial

Source: Internet
Author: User
Under Windows, get a user-defined data source by reading the registry

[Python]
#-*-Coding:utf-8-*-
# Get ODBC data source list
From Tkinter Import *
From Tkinter import TTK
Import Win32api,win32con


Def GETODBCDSN ():
Key = Win32API. RegOpenKey (Win32con. HKEY_CURRENT_USER,
' Software\\odbc\\odbc. Ini\\odbc Data Sources ', 0, Win32con. key_all_access)
#print (Key)
#print (Win32API. RegQueryValue (Key, "))
#print (' Number of subkeys returned, number of item values, and last modified time ', Win32API. RegQueryInfoKey (Key))
Subitem, item, Opdate =win32api. RegQueryInfoKey (Key)
Dsnlist=[]
For I in range (item):
Print ('---', win32api. RegEnumValue (key, i))
Dsnname,dsnobject,dsntype = Win32API. RegEnumValue (key, I)
Dsnlist.append (DSNname)
#print (dir (Win32API))
Win32API. RegCloseKey (Key)
Return dsnlist


Class Mframe (Frame):
def __init__ (self, Master=none, cnf={}, **kw):
Self.master = Master
Self.master.title (' Get user-defined data source ')
Self.combo = Ttk.combobox (self.master)
Self.combo.config (state= "ReadOnly")
Self.combo.pack (side=top, fill = ' x ', expand = False)
Self.combo.update_idletasks ()
COMLIST=GETODBCDSN ()
self.combo[' values '] = comlist


def test ():
GETODBCDSN ()
def main ():
root = Tk ()
Mf=mframe (Root)
Root.mainloop ()
If __name__== "__main__":
#test ()
Main ()

http://www.bkjia.com/PHPjc/477920.html www.bkjia.com true http://www.bkjia.com/PHPjc/477920.html techarticle windows, obtaining a user-defined data source by reading the registry [Python] #-*-coding:utf-8-*-# Get ODBC data source list from Tkinter Import * from Tkinter import TT K Import W ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.