summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2014-07-15 09:30:58 +0200
committerAraq <rumpf_a@web.de>2014-07-15 09:30:58 +0200
commit0743f78012e954f5295df7923ccabd472a5a7502 (patch)
tree5d681c9835f01019e8ae83e14c0cd49d1a6c0d38 /lib
parent7fa399f51c39e6661876223009d5003cd2e0cf99 (diff)
parent18ded6c23d72cd21fa0aa10ff61dc6f9af40832c (diff)
downloadNim-0743f78012e954f5295df7923ccabd472a5a7502.tar.gz
Merge branch 'master' of https://github.com/Araq/Nimrod
Diffstat (limited to 'lib')
-rw-r--r--lib/impure/db_mysql.nim9
-rw-r--r--lib/js/dom.nim3
-rw-r--r--lib/packages/docutils/rstgen.nim439
-rw-r--r--lib/posix/posix.nim17
-rw-r--r--lib/pure/algorithm.nim9
-rw-r--r--lib/pure/asyncdispatch.nim340
-rw-r--r--lib/pure/asynchttpserver.nim181
-rw-r--r--lib/pure/asyncnet.nim115
-rw-r--r--lib/pure/collections/sequtils.nim63
-rw-r--r--lib/pure/collections/sets.nim49
-rw-r--r--lib/pure/collections/tables.nim344
-rw-r--r--lib/pure/concurrency/cpuinfo.nim58
-rw-r--r--lib/pure/concurrency/cpuload.nim96
-rw-r--r--lib/pure/concurrency/threadpool.nim378
-rw-r--r--lib/pure/fsmonitor.nim6
-rw-r--r--lib/pure/future.nim1
-rw-r--r--lib/pure/hashes.nim29
-rw-r--r--lib/pure/httpclient.nim2
-rw-r--r--lib/pure/httpserver.nim2
-rw-r--r--lib/pure/json.nim85
-rw-r--r--lib/pure/math.nim24
-rw-r--r--lib/pure/memfiles.nim24
-rw-r--r--lib/pure/net.nim75
-rw-r--r--lib/pure/nimprof.nim13
-rw-r--r--lib/pure/oids.nim4
-rw-r--r--lib/pure/os.nim47
-rw-r--r--lib/pure/osproc.nim44
-rw-r--r--lib/pure/rawsockets.nim6
-rw-r--r--lib/pure/selectors.nim82
-rw-r--r--lib/pure/sockets.nim2
-rw-r--r--lib/pure/strutils.nim2
-rw-r--r--lib/pure/times.nim3
-rw-r--r--lib/system.nim115
-rw-r--r--lib/system/alloc.nim16
-rw-r--r--lib/system/ansi_c.nim3
-rw-r--r--lib/system/assign.nim3
-rw-r--r--lib/system/atomics.nim70
-rw-r--r--lib/system/chcks.nim22
-rw-r--r--lib/system/excpt.nim12
-rw-r--r--lib/system/gc_ms.nim53
-rw-r--r--lib/system/inclrtl.nim2
-rw-r--r--lib/system/sets.nim4
-rw-r--r--lib/system/sysio.nim12
-rw-r--r--lib/system/sysspawn.nim47
-rw-r--r--lib/system/threads.nim2
-rw-r--r--lib/windows/windows.nim1708
-rw-r--r--lib/windows/winlean.nim16
-rw-r--r--lib/wrappers/openssl.nim69
-rw-r--r--lib/wrappers/pdcurses.nim8
-rw-r--r--lib/wrappers/readline/readline.nim4
-rw-r--r--lib/wrappers/sqlite3.nim6
51 files changed, 3338 insertions, 1386 deletions
diff --git a/lib/impure/db_mysql.nim b/lib/impure/db_mysql.nim
index 32cda3e4d..eec4daf00 100644
--- a/lib/impure/db_mysql.nim
+++ b/lib/impure/db_mysql.nim
@@ -24,6 +24,15 @@ type
   FReadDb* = object of FDb   ## effect that denotes a read operation
   FWriteDb* = object of FDb  ## effect that denotes a write operation
 
+proc sql*(query: string): TSqlQuery {.noSideEffect, inline.} =
+  ## constructs a TSqlQuery from the string `query`. This is supposed to be 
+  ## used as a raw-string-literal modifier:
+  ## ``sql"update user set counter = counter + 1"``
+  ##
+  ## If assertions are turned off, it does nothing. If assertions are turned 
+  ## on, later versions will check the string for valid syntax.
+  result = TSqlQuery(query)
+
 proc dbError(db: TDbConn) {.noreturn.} = 
   ## raises an EDb exception.
   var e: ref EDb
diff --git a/lib/js/dom.nim b/lib/js/dom.nim
index d90067176..951d8e835 100644
--- a/lib/js/dom.nim
+++ b/lib/js/dom.nim
@@ -7,7 +7,8 @@
 #    distribution, for details about the copyright.
 #
 
-## Declaration of the Document Object Model for the JavaScript backend.
+## Declaration of the Document Object Model for the `JavaScript backend
+## <backends.html#the-javascript-target>`_.
 
 when not defined(js) and not defined(Nimdoc):
   {.error: "This module only works on the JavaScript platform".}
diff --git a/lib/packages/docutils/rstgen.nim b/lib/packages/docutils/rstgen.nim
index cead17f2b..fdbca4ca8 100644
--- a/lib/packages/docutils/rstgen.nim
+++ b/lib/packages/docutils/rstgen.nim
@@ -23,7 +23,8 @@
 ## many options and tweaking, but you are not limited to snippets and can
 ## generate `LaTeX documents <https://en.wikipedia.org/wiki/LaTeX>`_ too.
 
-import strutils, os, hashes, strtabs, rstast, rst, highlite
+import strutils, os, hashes, strtabs, rstast, rst, highlite, tables, sequtils,
+  algorithm
 
 const
   HtmlExt = "html"
@@ -56,6 +57,9 @@ type
     currentSection: string ## \
     ## Stores the empty string or the last headline/overline found in the rst
     ## document, so it can be used as a prettier name for term index generation.
+    seenIndexTerms: TTable[string, int] ## \
+    ## Keeps count of same text index terms to generate different identifiers
+    ## for hyperlinks. See renderIndexTerm proc for details.
   
   PDoc = var TRstGenerator ## Alias to type less.
 
@@ -68,10 +72,16 @@ proc initRstGenerator*(g: var TRstGenerator, target: TOutputTarget,
   ##
   ## You need to call this before using a ``TRstGenerator`` with any other
   ## procs in this module. Pass a non ``nil`` ``PStringTable`` value as
-  ## ``config`` with parameters used by the HTML output generator.  If you
-  ## don't know what to use, pass the results of the ``defaultConfig()`` proc.
-  ## The ``filename`` is symbolic and used only for error reporting, you can
-  ## pass any non ``nil`` string here.
+  ## `config` with parameters used by the HTML output generator.  If you don't
+  ## know what to use, pass the results of the `defaultConfig()
+  ## <#defaultConfig>_` proc.
+  ##
+  ## The `filename` parameter will be used for error reporting and creating
+  ## index hyperlinks to the file, but you can pass an empty string here if you
+  ## are parsing a stream in memory. If `filename` ends with the ``.nim``
+  ## extension, the title for the document will be set by default to ``Module
+  ## filename``.  This default title can be overriden by the embedded rst, but
+  ## it helps to prettify the generated index if no title is found.
   ##
   ## The ``TRstParseOptions``, ``TFindFileHandler`` and ``TMsgHandler`` types
   ## are defined in the the `packages/docutils/rst module <rst.html>`_.
@@ -111,6 +121,10 @@ proc initRstGenerator*(g: var TRstGenerator, target: TOutputTarget,
   g.options = options
   g.findFile = findFile
   g.currentSection = ""
+  let fileParts = filename.splitFile
+  if fileParts.ext == ".nim":
+    g.currentSection = "Module " & fileParts.name
+  g.seenIndexTerms = initTable[string, int]()
   g.msgHandler = msgHandler
   
   let s = config["split.item.toc"]
@@ -120,8 +134,8 @@ proc initRstGenerator*(g: var TRstGenerator, target: TOutputTarget,
 proc writeIndexFile*(g: var TRstGenerator, outfile: string) =
   ## Writes the current index buffer to the specified output file.
   ##
-  ## You previously need to add entries to the index with the ``setIndexTerm``
-  ## proc. If the index is empty the file won't be created.
+  ## You previously need to add entries to the index with the `setIndexTerm()
+  ## <#setIndexTerm>`_ proc. If the index is empty the file won't be created.
   if g.theIndex.len > 0: writeFile(outfile, g.theIndex)
   
 proc addXmlChar(dest: var string, c: char) = 
@@ -207,6 +221,9 @@ proc dispA(target: TOutputTarget, dest: var string,
   if target != outLatex: addf(dest, xml, args)
   else: addf(dest, tex, args)
   
+proc `or`(x, y: string): string {.inline.} =
+  result = if x.isNil: y else: x
+
 proc renderRstToOut*(d: var TRstGenerator, n: PRstNode, result: var string)
   ## Writes into ``result`` the rst ast ``n`` using the ``d`` configuration.
   ##
@@ -224,7 +241,7 @@ proc renderRstToOut*(d: var TRstGenerator, n: PRstNode, result: var string)
 proc renderAux(d: PDoc, n: PRstNode, result: var string) = 
   for i in countup(0, len(n)-1): renderRstToOut(d, n.sons[i], result)
 
-proc renderAux(d: PDoc, n: PRstNode, frmtA, frmtB: string, result: var string) = 
+proc renderAux(d: PDoc, n: PRstNode, frmtA, frmtB: string, result: var string) =
   var tmp = ""
   for i in countup(0, len(n)-1): renderRstToOut(d, n.sons[i], tmp)
   if d.target != outLatex:
@@ -254,25 +271,45 @@ proc setIndexTerm*(d: var TRstGenerator, id, term: string,
                    linkTitle, linkDesc = "") =
   ## Adds a `term` to the index using the specified hyperlink identifier.
   ##
-  ## The ``d.theIndex`` string will be used to append the term in the format
-  ## ``term<tab>file#id``. The anchor will be the based on the name of the file
-  ## currently being parsed plus the `id`, which will be appended after a hash.
+  ## A new entry will be added to the index using the format
+  ## ``term<tab>file#id``. The file part will come from the `filename`
+  ## parameter used in a previous call to the `initRstGenerator()
+  ## <#initRstGenerator>`_ proc.
+  ##
+  ## The `id` will be appended with a hash character only if its length is not
+  ## zero, otherwise no specific anchor will be generated. In general you
+  ## should only pass an empty `id` value for the title of standalone rst
+  ## documents (they are special for the `mergeIndexes() <#mergeIndexes>`_
+  ## proc, see `Index (idx) file format <docgen.html#index-idx-file-format>`_
+  ## for more information). Unlike other index terms, title entries are
+  ## inserted at the beginning of the accumulated buffer to maintain a logical
+  ## order of entries.
+  ##
   ## If `linkTitle` or `linkDesc` are not the empty string, two additional
   ## columns with their contents will be added.
   ##
-  ## The index won't be written to disk unless you call ``writeIndexFile``. The
-  ## purpose of the index is documented in the `docgen tools guide
-  ## <docgen.html#index-switch>`_.
-  d.theIndex.add(term)
-  d.theIndex.add('\t')
+  ## The index won't be written to disk unless you call `writeIndexFile()
+  ## <#writeIndexFile>`_. The purpose of the index is documented in the `docgen
+  ## tools guide <docgen.html#index-switch>`_.
+  assert(not d.theIndex.isNil)
+  var
+    entry = term
+    isTitle = false
+  entry.add('\t')
   let htmlFile = changeFileExt(extractFilename(d.filename), HtmlExt)
-  d.theIndex.add(htmlFile)
-  d.theIndex.add('#')
-  d.theIndex.add(id)
+  entry.add(htmlFile)
+  if id.len > 0:
+    entry.add('#')
+    entry.add(id)
+  else:
+    isTitle = true
   if linkTitle.len > 0 or linkDesc.len > 0:
-    d.theIndex.add('\t' & linkTitle.quoteIndexColumn)
-    d.theIndex.add('\t' & linkDesc.quoteIndexColumn)
-  d.theIndex.add("\n")
+    entry.add('\t' & linkTitle.quoteIndexColumn)
+    entry.add('\t' & linkDesc.quoteIndexColumn)
+  entry.add("\n")
+
+  if isTitle: d.theIndex.insert(entry)
+  else: d.theIndex.add(entry)
 
 proc hash(n: PRstNode): int =
   if n.kind == rnLeaf:
@@ -283,8 +320,20 @@ proc hash(n: PRstNode): int =
       result = result !& hash(n.sons[i])
     result = !$result
 
-proc renderIndexTerm(d: PDoc, n: PRstNode, result: var string) =
-  let id = rstnodeToRefname(n) & '_' & $abs(hash(n))
+proc renderIndexTerm*(d: PDoc, n: PRstNode, result: var string) =
+  ## Renders the string decorated within \`foobar\`\:idx\: markers.
+  ##
+  ## Additionally adds the encosed text to the index as a term. Since we are
+  ## interested in different instances of the same term to have different
+  ## entries, a table is used to keep track of the amount of times a term has
+  ## previously appeared to give a different identifier value for each.
+  let refname = n.rstnodeToRefname
+  if d.seenIndexTerms.hasKey(refname):
+    d.seenIndexTerms[refname] = d.seenIndexTerms[refname] + 1
+  else:
+    d.seenIndexTerms[refname] = 1
+  let id = refname & '_' & $d.seenIndexTerms[refname]
+
   var term = ""
   renderAux(d, n, term)
   setIndexTerm(d, id, term, d.currentSection)
@@ -298,12 +347,34 @@ type
     linkTitle: string ## If not nil, contains a prettier text for the href
     linkDesc: string ## If not nil, the title attribute of the final href
 
+  TIndexedDocs {.pure, final.} = TTable[TIndexEntry, seq[TIndexEntry]] ## \
+    ## Contains the index sequences for doc types.
+    ##
+    ## The key is a *fake* TIndexEntry which will contain the title of the
+    ## document in the `keyword` field and `link` will contain the html
+    ## filename for the document. `linkTitle` and `linkDesc` will be nil.
+    ##
+    ## The value indexed by this TIndexEntry is a sequence with the real index
+    ## entries found in the ``.idx`` file.
+
+
 proc cmp(a, b: TIndexEntry): int =
   ## Sorts two ``TIndexEntry`` first by `keyword` field, then by `link`.
   result = cmpIgnoreStyle(a.keyword, b.keyword)
   if result == 0:
     result = cmpIgnoreStyle(a.link, b.link)
 
+proc hash(x: TIndexEntry): THash =
+  ## Returns the hash for the combined fields of the type.
+  ##
+  ## The hash is computed as the chained hash of the individual string hashes.
+  assert(not x.keyword.isNil)
+  assert(not x.link.isNil)
+  result = x.keyword.hash !& x.link.hash
+  result = result !& (x.linkTitle or "").hash
+  result = result !& (x.linkDesc or "").hash
+  result = !$result
+
 proc `<-`(a: var TIndexEntry, b: TIndexEntry) =
   shallowCopy a.keyword, b.keyword
   shallowCopy a.link, b.link
@@ -332,43 +403,18 @@ proc sortIndex(a: var openArray[TIndexEntry]) =
       a[j] <- v
     if h == 1: break
 
-proc mergeIndexes*(dir: string): string =
-  ## merges all index files in `dir` and returns the generated index as HTML.
-  ## The result is no full HTML for flexibility.
-  var a: seq[TIndexEntry]
-  newSeq(a, 15_000)
-  setLen(a, 0)
-  var L = 0
-  for kind, path in walkDir(dir):
-    if kind == pcFile and path.endsWith(IndexExt):
-      for line in lines(path):
-        let s = line.find('\t')
-        if s < 0: continue
-        setLen(a, L+1)
-        a[L].keyword = line.substr(0, s-1)
-        a[L].link = line.substr(s+1)
-        if a[L].link.find('\t') > 0:
-          let extraCols = a[L].link.split('\t')
-          a[L].link = extraCols[0]
-          assert extraCols.len == 3
-          a[L].linkTitle = extraCols[1].unquoteIndexColumn
-          a[L].linkDesc = extraCols[2].unquoteIndexColumn
-        else:
-          a[L].linkTitle = nil
-          a[L].linkDesc = nil
-        inc L
-  sortIndex(a)
+proc generateSymbolIndex(symbols: seq[TIndexEntry]): string =
   result = ""
   var i = 0
-  while i < L:
-    result.addf("<dt><span>$1</span></dt><ul class=\"simple\"><dd>\n", 
-                [a[i].keyword])
+  while i < symbols.len:
+    result.addf("<dt><span>$1:</span></dt><ul class=\"simple\"><dd>\n",
+                [symbols[i].keyword])
     var j = i
-    while j < L and a[i].keyword == a[j].keyword:
+    while j < symbols.len and symbols[i].keyword == symbols[j].keyword:
       let
-        url = a[j].link
-        text = if not a[j].linkTitle.isNil: a[j].linkTitle else: url
-        desc = if not a[j].linkDesc.isNil: a[j].linkDesc else: ""
+        url = symbols[j].link
+        text = if not symbols[j].linkTitle.isNil: symbols[j].linkTitle else: url
+        desc = if not symbols[j].linkDesc.isNil: symbols[j].linkDesc else: ""
       if desc.len > 0:
         result.addf("""<li><a class="reference external"
           title="$3" href="$1">$2</a></li>
@@ -379,9 +425,246 @@ proc mergeIndexes*(dir: string): string =
       inc j
     result.add("</ul></dd>\n")
     i = j
+
+proc isDocumentationTitle(hyperlink: string): bool =
+  ## Returns true if the hyperlink is actually a documentation title.
+  ##
+  ## Documentation titles lack the hash. See `mergeIndexes() <#mergeIndexes>`_
+  ## for a more detailed explanation.
+  result = hyperlink.find('#') < 0
+
+proc stripTOCLevel(s: string): tuple[level: int, text: string] =
+  ## Returns the *level* of the toc along with the text without it.
+  for c in 0 .. <s.len:
+    result.level = c
+    if s[c] != ' ': break
+  result.text = s[result.level .. <s.len]
+
+proc indentToLevel(level: var int, newLevel: int): string =
+  ## Returns the sequence of <ul>|</ul> characters to switch to `newLevel`.
+  ##
+  ## The amount of lists added/removed will be based on the `level` variable,
+  ## which will be reset to `newLevel` at the end of the proc.
+  result = ""
+  if level == newLevel:
+    return
+  if newLevel > level:
+    result = repeatStr(newLevel - level, "<ul>")
+  else:
+    result = repeatStr(level - newLevel, "</ul>")
+  level = newLevel
+
+proc generateDocumentationTOC(entries: seq[TIndexEntry]): string =
+  ## Returns the sequence of index entries in an HTML hierarchical list.
+  result = ""
+  # Build a list of levels and extracted titles to make processing easier.
+  var
+    titleRef: string
+    levels: seq[tuple[level: int, text: string]]
+    L = 0
+    level = 1
+  levels.newSeq(entries.len)
+  for entry in entries:
+    let (rawLevel, rawText) = stripTOCLevel(entry.linkTitle or entry.keyword)
+    if rawLevel < 1:
+      # This is a normal symbol, push it *inside* one level from the last one.
+      levels[L].level = level + 1
+      # Also, ignore the linkTitle and use directly the keyword.
+      levels[L].text = entry.keyword
+    else:
+      # The level did change, update the level indicator.
+      level = rawLevel
+      levels[L].level = rawLevel
+      levels[L].text = rawText
+    inc L
+
+  # Now generate hierarchical lists based on the precalculated levels.
+  result = "<ul>\n"
+  level = 1
+  L = 0
+  while L < entries.len:
+    let link = entries[L].link
+    if link.isDocumentationTitle:
+      titleRef = link
+    else:
+      result.add(level.indentToLevel(levels[L].level))
+      result.add("<li><a href=\"" & link & "\">" &
+        levels[L].text & "</a>\n")
+    inc L
+  result.add(level.indentToLevel(1) & "</ul>\n")
+  assert(not titleRef.isNil,
+    "Can't use this proc on an API index, docs always have a title entry")
+
+proc generateDocumentationIndex(docs: TIndexedDocs): string =
+  ## Returns all the documentation TOCs in an HTML hierarchical list.
+  result = ""
+
+  # Sort the titles to generate their toc in alphabetical order.
+  var titles = toSeq(keys[TIndexEntry, seq[TIndexEntry]](docs))
+  sort(titles, cmp)
+
+  for title in titles:
+    let tocList = generateDocumentationTOC(docs[title])
+    result.add("<ul><li><a href=\"" &
+      title.link & "\">" & title.keyword & "</a>\n" & tocList & "</ul>\n")
+
+proc generateDocumentationJumps(docs: TIndexedDocs): string =
+  ## Returns a plain list of hyperlinks to documentation TOCs in HTML.
+  result = "Documents: "
+
+  # Sort the titles to generate their toc in alphabetical order.
+  var titles = toSeq(keys[TIndexEntry, seq[TIndexEntry]](docs))
+  sort(titles, cmp)
+
+  var chunks: seq[string] = @[]
+  for title in titles:
+    chunks.add("<a href=\"" & title.link & "\">" & title.keyword & "</a>")
+
+  result.add(chunks.join(", ") & ".<br>")
+
+proc generateModuleJumps(modules: seq[string]): string =
+  ## Returns a plain list of hyperlinks to the list of modules.
+  result = "Modules: "
+
+  var chunks: seq[string] = @[]
+  for name in modules:
+    chunks.add("<a href=\"" & name & ".html\">" & name & "</a>")
+
+  result.add(chunks.join(", ") & ".<br>")
+
+proc readIndexDir(dir: string):
+    tuple[modules: seq[string], symbols: seq[TIndexEntry], docs: TIndexedDocs] =
+  ## Walks `dir` reading ``.idx`` files converting them in TIndexEntry items.
+  ##
+  ## Returns the list of found module names, the list of free symbol entries
+  ## and the different documentation indexes. The list of modules is sorted.
+  ## See the documentation of ``mergeIndexes`` for details.
+  result.modules = @[]
+  result.docs = initTable[TIndexEntry, seq[TIndexEntry]](32)
+  newSeq(result.symbols, 15_000)
+  setLen(result.symbols, 0)
+  var L = 0
+  # Scan index files and build the list of symbols.
+  for kind, path in walkDir(dir):
+    if kind == pcFile and path.endsWith(IndexExt):
+      var
+        fileEntries: seq[TIndexEntry]
+        title: TIndexEntry
+        F = 0
+      newSeq(fileEntries, 500)
+      setLen(fileEntries, 0)
+      for line in lines(path):
+        let s = line.find('\t')
+        if s < 0: continue
+        setLen(fileEntries, F+1)
+        fileEntries[F].keyword = line.substr(0, s-1)
+        fileEntries[F].link = line.substr(s+1)
+        # See if we detect a title, a link without a `#foobar` trailing part.
+        if title.keyword.isNil and fileEntries[F].link.isDocumentationTitle:
+          title.keyword = fileEntries[F].keyword
+          title.link = fileEntries[F].link
+
+        if fileEntries[F].link.find('\t') > 0:
+          let extraCols = fileEntries[F].link.split('\t')
+          fileEntries[F].link = extraCols[0]
+          assert extraCols.len == 3
+          fileEntries[F].linkTitle = extraCols[1].unquoteIndexColumn
+          fileEntries[F].linkDesc = extraCols[2].unquoteIndexColumn
+        else:
+          fileEntries[F].linkTitle = nil
+          fileEntries[F].linkDesc = nil
+        inc F
+      # Depending on type add this to the list of symbols or table of APIs.
+      if title.keyword.isNil:
+        for i in 0 .. <F:
+          # Don't add to symbols TOC entries (they start with a whitespace).
+          let toc = fileEntries[i].linkTitle
+          if not toc.isNil and toc.len > 0 and toc[0] == ' ':
+            continue
+          # Ok, non TOC entry, add it.
+          setLen(result.symbols, L + 1)
+          result.symbols[L] = fileEntries[i]
+          inc L
+        result.modules.add(path.splitFile.name)
+      else:
+        # Generate the symbolic anchor for index quickjumps.
+        title.linkTitle = "doc_toc_" & $result.docs.len
+        result.docs[title] = fileEntries
+
+  sort(result.modules, system.cmp)
+
+proc mergeIndexes*(dir: string): string =
+  ## Merges all index files in `dir` and returns the generated index as HTML.
+  ##
+  ## This proc will first scan `dir` for index files with the ``.idx``
+  ## extension previously created by commands like ``nimrod doc|rst2html``
+  ## which use the ``--index:on`` switch. These index files are the result of
+  ## calls to `setIndexTerm() <#setIndexTerm>`_ and `writeIndexFile()
+  ## <#writeIndexFile>`_, so they are simple tab separated files.
+  ##
+  ## As convention this proc will split index files into two categories:
+  ## documentation and API. API indices will be all joined together into a
+  ## single big sorted index, making the bulk of the final index. This is good
+  ## for API documentation because many symbols are repated in different
+  ## modules. On the other hand, documentation indices are essentially table of
+  ## contents plus a few special markers. These documents will be rendered in a
+  ## separate section which tries to maintain the order and hierarchy of the
+  ## symbols in the index file.
+  ##
+  ## To differentiate between a documentation and API file a convention is
+  ## used: indices which contain one entry without the HTML hash character (#)
+  ## will be considered `documentation`, since this hash-less entry is the
+  ## explicit title of the document.  Indices without this explicit entry will
+  ## be considered `generated API` extracted out of a source ``.nim`` file.
+  ##
+  ## Returns the merged and sorted indices into a single HTML block which can
+  ## be further embedded into nimdoc templates.
+  var (modules, symbols, docs) = readIndexDir(dir)
+  assert(not symbols.isNil)
+
+  result = ""
+  # Generate a quick jump list of documents.
+  if docs.len > 0:
+    result.add(generateDocumentationJumps(docs))
+    result.add("<p />")
+
+  # Generate hyperlinks to all the linked modules.
+  if modules.len > 0:
+    result.add(generateModuleJumps(modules))
+    result.add("<p />")
+
+  # Generate the HTML block with API documents.
+  if docs.len > 0:
+    result.add("<h2>Documentation files</h2>\n")
+    result.add(generateDocumentationIndex(docs))
+
+  # Generate the HTML block with symbols.
+  if symbols.len > 0:
+    sortIndex(symbols)
+    result.add("<h2>API symbols</h2>\n")
+    result.add(generateSymbolIndex(symbols))
+
   
-# ----------------------------------------------------------------------------      
-  
+# ----------------------------------------------------------------------------
+
+proc stripTOCHTML(s: string): string =
+  ## Ugly quick hack to remove HTML tags from TOC titles.
+  ##
+  ## A TTocEntry.header field already contains rendered HTML tags. Instead of
+  ## implementing a proper version of renderRstToOut() which recursively
+  ## renders an rst tree to plain text, we simply remove text found between
+  ## angled brackets. Given the limited possibilities of rst inside TOC titles
+  ## this should be enough.
+  result = s
+  var first = result.find('<')
+  while first >= 0:
+    let last = result.find('>', first)
+    if last < 0:
+      # Abort, since we didn't found a closing angled bracket.
+      return
+    result.delete(first, last)
+    first = result.find('<', first)
+
 proc renderHeadline(d: PDoc, n: PRstNode, result: var string) = 
   var tmp = ""
   for i in countup(0, len(n) - 1): renderRstToOut(d, n.sons[i], tmp)
@@ -393,27 +676,30 @@ proc renderHeadline(d: PDoc, n: PRstNode, result: var string) =
     d.tocPart[length].refname = refname
     d.tocPart[length].n = n
     d.tocPart[length].header = tmp
-    
-    dispA(d.target, result,
-        "\n<h$1><a class=\"toc-backref\" id=\"$2\" href=\"#$2_toc\">$3</a></h$1>", 
-        "\\rsth$4{$3}\\label{$2}\n", [$n.level, 
-        d.tocPart[length].refname, tmp, 
-        $chr(n.level - 1 + ord('A'))])
+
+    dispA(d.target, result, "\n<h$1><a class=\"toc-backref\" " &
+      "id=\"$2\" href=\"#$2_toc\">$3</a></h$1>", "\\rsth$4{$3}\\label{$2}\n",
+      [$n.level, d.tocPart[length].refname, tmp, $chr(n.level - 1 + ord('A'))])
   else:
     dispA(d.target, result, "\n<h$1 id=\"$2\">$3</h$1>", 
                             "\\rsth$4{$3}\\label{$2}\n", [
         $n.level, refname, tmp, 
         $chr(n.level - 1 + ord('A'))])
-  
+
+  # Generate index entry using spaces to indicate TOC level for the output HTML.
+  assert n.level >= 0
+  setIndexTerm(d, refname, tmp.stripTOCHTML,
+    repeatChar(max(0, n.level), ' ') & tmp)
+
 proc renderOverline(d: PDoc, n: PRstNode, result: var string) = 
   if d.meta[metaTitle].len == 0:
-    d.currentSection = d.meta[metaTitle]
     for i in countup(0, len(n)-1):
       renderRstToOut(d, n.sons[i], d.meta[metaTitle])
+    d.currentSection = d.meta[metaTitle]
   elif d.meta[metaSubtitle].len == 0:
-    d.currentSection = d.meta[metaSubtitle]
     for i in countup(0, len(n)-1):
       renderRstToOut(d, n.sons[i], d.meta[metaSubtitle])
+    d.currentSection = d.meta[metaSubtitle]
   else:
     var tmp = ""
     for i in countup(0, len(n) - 1): renderRstToOut(d, n.sons[i], tmp)
@@ -428,7 +714,8 @@ proc renderTocEntry(d: PDoc, e: TTocEntry, result: var string) =
     "<li><a class=\"reference\" id=\"$1_toc\" href=\"#$1\">$2</a></li>\n", 
     "\\item\\label{$1_toc} $2\\ref{$1}\n", [e.refname, e.header])
 
-proc renderTocEntries*(d: var TRstGenerator, j: var int, lvl: int, result: var string) =
+proc renderTocEntries*(d: var TRstGenerator, j: var int, lvl: int,
+    result: var string) =
   var tmp = ""
   while j <= high(d.tocPart): 
     var a = abs(d.tocPart[j].n.level)
@@ -572,7 +859,8 @@ proc renderRstToOut(d: PDoc, n: PRstNode, result: var string) =
           [tmp])
   of rnField: renderField(d, n, result)
   of rnFieldName: 
-    renderAux(d, n, "<th class=\"docinfo-name\">$1:</th>", "\\item[$1:]", result)
+    renderAux(d, n, "<th class=\"docinfo-name\">$1:</th>",
+                    "\\item[$1:]", result)
   of rnFieldBody: 
     renderAux(d, n, "<td>$1</td>", " $1\n", result)
   of rnIndex: 
@@ -631,8 +919,9 @@ proc renderRstToOut(d: PDoc, n: PRstNode, result: var string) =
   of rnRef: 
     var tmp = ""
     renderAux(d, n, tmp)
-    dispA(d.target, result, "<a class=\"reference external\" href=\"#$2\">$1</a>", 
-                            "$1\\ref{$2}", [tmp, rstnodeToRefname(n)])
+    dispA(d.target, result,
+      "<a class=\"reference external\" href=\"#$2\">$1</a>",
+      "$1\\ref{$2}", [tmp, rstnodeToRefname(n)])
   of rnStandaloneHyperlink: 
     renderAux(d, n, 
       "<a class=\"reference external\" href=\"$1\">$1</a>", 
@@ -642,9 +931,9 @@ proc renderRstToOut(d: PDoc, n: PRstNode, result: var string) =
     var tmp1 = ""
     renderRstToOut(d, n.sons[0], tmp0)
     renderRstToOut(d, n.sons[1], tmp1)
-    dispA(d.target, result, "<a class=\"reference external\" href=\"$2\">$1</a>", 
-                   "\\href{$2}{$1}", 
-                   [tmp0, tmp1])
+    dispA(d.target, result,
+      "<a class=\"reference external\" href=\"$2\">$1</a>",
+      "\\href{$2}{$1}", [tmp0, tmp1])
   of rnDirArg, rnRaw: renderAux(d, n, result)
   of rnRawHtml:
     if d.target != outLatex:
diff --git a/lib/posix/posix.nim b/lib/posix/posix.nim
index e206447cc..8e66336c2 100644
--- a/lib/posix/posix.nim
+++ b/lib/posix/posix.nim
@@ -846,7 +846,7 @@ var
   FE_UPWARD* {.importc, header: "<fenv.h>".}: cint
   FE_DFL_ENV* {.importc, header: "<fenv.h>".}: cint
 
-when not defined(haiku):
+when not defined(haiku) and not defined(OpenBSD):
   var
     MM_HARD* {.importc, header: "<fmtmsg.h>".}: cint
       ## Source of the condition is hardware.
@@ -1578,8 +1578,17 @@ var
     ## Terminates a record (if supported by the protocol).
   MSG_OOB* {.importc, header: "<sys/socket.h>".}: cint
     ## Out-of-band data.
-  MSG_NOSIGNAL* {.importc, header: "<sys/socket.h>".}: cint
-    ## No SIGPIPE generated when an attempt to send is made on a stream-oriented socket that is no longer connected.
+
+when defined(macosx):
+  var
+    MSG_HAVEMORE* {.importc, header: "<sys/socket.h>".}: cint
+    MSG_NOSIGNAL* = MSG_HAVEMORE
+else:
+  var
+    MSG_NOSIGNAL* {.importc, header: "<sys/socket.h>".}: cint
+      ## No SIGPIPE generated when an attempt to send is made on a stream-oriented socket that is no longer connected.
+
+var
   MSG_PEEK* {.importc, header: "<sys/socket.h>".}: cint
     ## Leave received data in queue.
   MSG_TRUNC* {.importc, header: "<sys/socket.h>".}: cint
@@ -1816,7 +1825,7 @@ proc feholdexcept*(a1: ptr Tfenv): cint {.importc, header: "<fenv.h>".}
 proc fesetenv*(a1: ptr Tfenv): cint {.importc, header: "<fenv.h>".}
 proc feupdateenv*(a1: ptr Tfenv): cint {.importc, header: "<fenv.h>".}
 
-when not defined(haiku):
+when not defined(haiku) and not defined(OpenBSD):
   proc fmtmsg*(a1: int, a2: cstring, a3: cint,
               a4, a5, a6: cstring): cint {.importc, header: "<fmtmsg.h>".}
 
diff --git a/lib/pure/algorithm.nim b/lib/pure/algorithm.nim
index 37fbc948c..86d329763 100644
--- a/lib/pure/algorithm.nim
+++ b/lib/pure/algorithm.nim
@@ -150,6 +150,15 @@ proc sort*[T](a: var openArray[T],
   ##    # overload:
   ##    sort(myStrArray, system.cmp)
   ##
+  ## You can inline adhoc comparison procs with the `do notation
+  ## <manual.html#do-notation>`_. Example:
+  ##
+  ## .. code-block:: nimrod
+  ##
+  ##   people.sort do (x, y: Person) -> int:
+  ##     result = cmp(x.surname, y.surname)
+  ##     if result == 0:
+  ##       result = cmp(x.name, y.name)
   var n = a.len
   var b: seq[T]
   newSeq(b, n div 2)
diff --git a/lib/pure/asyncdispatch.nim b/lib/pure/asyncdispatch.nim
index f50383038..d410f8ce1 100644
--- a/lib/pure/asyncdispatch.nim
+++ b/lib/pure/asyncdispatch.nim
@@ -11,8 +11,11 @@ include "system/inclrtl"
 
 import os, oids, tables, strutils, macros
 
-import rawsockets
-export TPort
+import rawsockets, net
+
+export TPort, TSocketFlags
+
+#{.injectStmt: newGcInvariant().}
 
 ## AsyncDispatch
 ## -------------
@@ -24,10 +27,12 @@ export TPort
 ## **Note:** This module is still largely experimental.
 
 
-# TODO: Discarded void PFutures need to checked for exception.
-# TODO: Exceptions are currently uncatchable due to the limitation that 
-# you cannot have yield in a try stmt. Perhaps I can get the macro to put
-# a user's try except around ``future.read``.
+# TODO: Discarded void PFutures need to be checked for exception.
+# TODO: ``except`` statement (without `try`) does not work.
+# TODO: Multiple exception names in a ``except`` don't work.
+# TODO: The effect system (raises: []) has trouble with my try transformation.
+# TODO: Can't await in a 'except' body
+# TODO: getCurrentException(Msg) don't work
 
 # -- Futures
 
@@ -35,19 +40,33 @@ type
   PFutureBase* = ref object of PObject
     cb: proc () {.closure,gcsafe.}
     finished: bool
+    error*: ref EBase
+    stackTrace: string ## For debugging purposes only.
 
   PFuture*[T] = ref object of PFutureBase
     value: T
-    error*: ref EBase # TODO: This shouldn't be necessary, generics bug?
 
 proc newFuture*[T](): PFuture[T] =
   ## Creates a new future.
   new(result)
   result.finished = false
+  result.stackTrace = getStackTrace()
+
+proc checkFinished[T](future: PFuture[T]) =
+  if future.finished:
+    echo("<----->")
+    echo(future.stackTrace)
+    echo("-----")
+    when T is string:
+      echo("Contents: ", future.value.repr)
+    echo("<----->")
+    echo("Future already finished, cannot finish twice.")
+    assert false
 
 proc complete*[T](future: PFuture[T], val: T) =
   ## Completes ``future`` with value ``val``.
-  assert(not future.finished, "Future already finished, cannot finish twice.")
+  #assert(not future.finished, "Future already finished, cannot finish twice.")
+  checkFinished(future)
   assert(future.error == nil)
   future.value = val
   future.finished = true
@@ -56,7 +75,8 @@ proc complete*[T](future: PFuture[T], val: T) =
 
 proc complete*(future: PFuture[void]) =
   ## Completes a void ``future``.
-  assert(not future.finished, "Future already finished, cannot finish twice.")
+  #assert(not future.finished, "Future already finished, cannot finish twice.")
+  checkFinished(future)
   assert(future.error == nil)
   future.finished = true
   if future.cb != nil:
@@ -64,11 +84,18 @@ proc complete*(future: PFuture[void]) =
 
 proc fail*[T](future: PFuture[T], error: ref EBase) =
   ## Completes ``future`` with ``error``.
-  assert(not future.finished, "Future already finished, cannot finish twice.")
+  #assert(not future.finished, "Future already finished, cannot finish twice.")
+  checkFinished(future)
   future.finished = true
   future.error = error
   if future.cb != nil:
     future.cb()
+  else:
+    # This is to prevent exceptions from being silently ignored when a future
+    # is discarded.
+    # TODO: This may turn out to be a bad idea.
+    # Turns out this is a bad idea.
+    #raise error
 
 proc `callback=`*(future: PFutureBase, cb: proc () {.closure,gcsafe.}) =
   ## Sets the callback proc to be called when the future completes.
@@ -112,10 +139,19 @@ proc finished*[T](future: PFuture[T]): bool =
   ## ``True`` may indicate an error or a value. Use ``failed`` to distinguish.
   future.finished
 
-proc failed*[T](future: PFuture[T]): bool =
+proc failed*(future: PFutureBase): bool =
   ## Determines whether ``future`` completed with an error.
   future.error != nil
 
+proc asyncCheck*[T](future: PFuture[T]) =
+  ## Sets a callback on ``future`` which raises an exception if the future
+  ## finished with an error.
+  ##
+  ## This should be used instead of ``discard`` to discard void futures.
+  future.callback =
+    proc () =
+      if future.failed: raise future.error
+
 when defined(windows) or defined(nimdoc):
   import winlean, sets, hashes
   type
@@ -130,15 +166,10 @@ when defined(windows) or defined(nimdoc):
       ioPort: THandle
       handles: TSet[TAsyncFD]
 
-    TCustomOverlapped = object
-      Internal*: DWORD
-      InternalHigh*: DWORD
-      Offset*: DWORD
-      OffsetHigh*: DWORD
-      hEvent*: THANDLE
+    TCustomOverlapped = object of TOVERLAPPED
       data*: TCompletionData
 
-    PCustomOverlapped = ptr TCustomOverlapped
+    PCustomOverlapped = ref TCustomOverlapped
 
     TAsyncFD* = distinct int
 
@@ -184,27 +215,27 @@ when defined(windows) or defined(nimdoc):
       else: timeout.int32
     var lpNumberOfBytesTransferred: DWORD
     var lpCompletionKey: ULONG
-    var lpOverlapped: POverlapped
-    let res = GetQueuedCompletionStatus(p.ioPort, addr lpNumberOfBytesTransferred,
-        addr lpCompletionKey, addr lpOverlapped, llTimeout).bool
+    var customOverlapped: PCustomOverlapped
+    let res = GetQueuedCompletionStatus(p.ioPort,
+        addr lpNumberOfBytesTransferred, addr lpCompletionKey,
+        cast[ptr POverlapped](addr customOverlapped), llTimeout).bool
 
     # http://stackoverflow.com/a/12277264/492186
     # TODO: http://www.serverframework.com/handling-multiple-pending-socket-read-and-write-operations.html
-    var customOverlapped = cast[PCustomOverlapped](lpOverlapped)
     if res:
       # This is useful for ensuring the reliability of the overlapped struct.
       assert customOverlapped.data.sock == lpCompletionKey.TAsyncFD
 
       customOverlapped.data.cb(customOverlapped.data.sock,
           lpNumberOfBytesTransferred, TOSErrorCode(-1))
-      dealloc(customOverlapped)
+      GC_unref(customOverlapped)
     else:
       let errCode = osLastError()
-      if lpOverlapped != nil:
+      if customOverlapped != nil:
         assert customOverlapped.data.sock == lpCompletionKey.TAsyncFD
         customOverlapped.data.cb(customOverlapped.data.sock,
             lpNumberOfBytesTransferred, errCode)
-        dealloc(customOverlapped)
+        GC_unref(customOverlapped)
       else:
         if errCode.int32 == WAIT_TIMEOUT:
           # Timed out
@@ -300,7 +331,8 @@ when defined(windows) or defined(nimdoc):
     while it != nil:
       # "the OVERLAPPED structure must remain valid until the I/O completes"
       # http://blogs.msdn.com/b/oldnewthing/archive/2011/02/02/10123392.aspx
-      var ol = cast[PCustomOverlapped](alloc0(sizeof(TCustomOverlapped)))
+      var ol = PCustomOverlapped()
+      GC_ref(ol)
       ol.data = TCompletionData(sock: socket, cb:
         proc (sock: TAsyncFD, bytesCount: DWord, errcode: TOSErrorCode) =
           if not retFuture.finished:
@@ -328,7 +360,7 @@ when defined(windows) or defined(nimdoc):
           success = true
           break
         else:
-          dealloc(ol)
+          GC_unref(ol)
           success = false
       it = it.ai_next
 
@@ -338,7 +370,7 @@ when defined(windows) or defined(nimdoc):
     return retFuture
 
   proc recv*(socket: TAsyncFD, size: int,
-             flags: int = 0): PFuture[string] =
+             flags = {TSocketFlags.SafeDisconn}): PFuture[string] =
     ## Reads **up to** ``size`` bytes from ``socket``. Returned future will
     ## complete once all the data requested is read, a part of the data has been
     ## read, or the socket has disconnected in which case the future will
@@ -352,15 +384,15 @@ when defined(windows) or defined(nimdoc):
     #     '\0' in the message currently signifies a socket disconnect. Who
     #     knows what will happen when someone sends that to our socket.
     verifyPresence(socket)
-    var retFuture = newFuture[string]()
-    
+    var retFuture = newFuture[string]()    
     var dataBuf: TWSABuf
     dataBuf.buf = cast[cstring](alloc0(size))
     dataBuf.len = size
     
     var bytesReceived: DWord
-    var flagsio = flags.DWord
-    var ol = cast[PCustomOverlapped](alloc0(sizeof(TCustomOverlapped)))
+    var flagsio = flags.toOSFlags().DWord
+    var ol = PCustomOverlapped()
+    GC_ref(ol)
     ol.data = TCompletionData(sock: socket, cb:
       proc (sock: TAsyncFD, bytesCount: DWord, errcode: TOSErrorCode) =
         if not retFuture.finished:
@@ -374,7 +406,9 @@ when defined(windows) or defined(nimdoc):
               retFuture.complete($data)
           else:
             retFuture.fail(newException(EOS, osErrorMsg(errcode)))
-        dealloc dataBuf.buf
+        if dataBuf.buf != nil:
+          dealloc dataBuf.buf
+          dataBuf.buf = nil
     )
 
     let ret = WSARecv(socket.TSocketHandle, addr dataBuf, 1, addr bytesReceived,
@@ -382,9 +416,14 @@ when defined(windows) or defined(nimdoc):
     if ret == -1:
       let err = osLastError()
       if err.int32 != ERROR_IO_PENDING:
-        dealloc dataBuf.buf
-        dealloc(ol)
-        retFuture.fail(newException(EOS, osErrorMsg(err)))
+        if dataBuf.buf != nil:
+          dealloc dataBuf.buf
+          dataBuf.buf = nil
+        GC_unref(ol)
+        if flags.isDisconnectionError(err):
+          retFuture.complete("")
+        else:
+          retFuture.fail(newException(EOS, osErrorMsg(err)))
     elif ret == 0 and bytesReceived == 0 and dataBuf.buf[0] == '\0':
       # We have to ensure that the buffer is empty because WSARecv will tell
       # us immediatelly when it was disconnected, even when there is still
@@ -415,7 +454,8 @@ when defined(windows) or defined(nimdoc):
       # free ``ol``.
     return retFuture
 
-  proc send*(socket: TAsyncFD, data: string): PFuture[void] =
+  proc send*(socket: TAsyncFD, data: string,
+             flags = {TSocketFlags.SafeDisconn}): PFuture[void] =
     ## Sends ``data`` to ``socket``. The returned future will complete once all
     ## data has been sent.
     verifyPresence(socket)
@@ -425,8 +465,9 @@ when defined(windows) or defined(nimdoc):
     dataBuf.buf = data # since this is not used in a callback, this is fine
     dataBuf.len = data.len
 
-    var bytesReceived, flags: DWord
-    var ol = cast[PCustomOverlapped](alloc0(sizeof(TCustomOverlapped)))
+    var bytesReceived, lowFlags: DWord
+    var ol = PCustomOverlapped()
+    GC_ref(ol)
     ol.data = TCompletionData(sock: socket, cb:
       proc (sock: TAsyncFD, bytesCount: DWord, errcode: TOSErrorCode) =
         if not retFuture.finished:
@@ -437,12 +478,15 @@ when defined(windows) or defined(nimdoc):
     )
 
     let ret = WSASend(socket.TSocketHandle, addr dataBuf, 1, addr bytesReceived,
-                      flags, cast[POverlapped](ol), nil)
+                      lowFlags, cast[POverlapped](ol), nil)
     if ret == -1:
       let err = osLastError()
       if err.int32 != ERROR_IO_PENDING:
-        retFuture.fail(newException(EOS, osErrorMsg(err)))
-        dealloc(ol)
+        GC_unref(ol)
+        if flags.isDisconnectionError(err):
+          retFuture.complete()
+        else:
+          retFuture.fail(newException(EOS, osErrorMsg(err)))
     else:
       retFuture.complete()
       # We don't deallocate ``ol`` here because even though this completed
@@ -490,7 +534,8 @@ when defined(windows) or defined(nimdoc):
          client: clientSock.TAsyncFD)
       )
 
-    var ol = cast[PCustomOverlapped](alloc0(sizeof(TCustomOverlapped)))
+    var ol = PCustomOverlapped()
+    GC_ref(ol)
     ol.data = TCompletionData(sock: socket, cb:
       proc (sock: TAsyncFD, bytesCount: DWord, errcode: TOSErrorCode) =
         if not retFuture.finished:
@@ -511,7 +556,7 @@ when defined(windows) or defined(nimdoc):
       let err = osLastError()
       if err.int32 != ERROR_IO_PENDING:
         retFuture.fail(newException(EOS, osErrorMsg(err)))
-        dealloc(ol)
+        GC_unref(ol)
     else:
       completeAccept()
       # We don't deallocate ``ol`` here because even though this completed
@@ -528,15 +573,30 @@ when defined(windows) or defined(nimdoc):
     result.TSocketHandle.setBlocking(false)
     register(result)
 
-  proc close*(socket: TAsyncFD) =
+  proc closeSocket*(socket: TAsyncFD) =
     ## Closes a socket and ensures that it is unregistered.
     socket.TSocketHandle.close()
     getGlobalDispatcher().handles.excl(socket)
 
+  proc unregister*(fd: TAsyncFD) =
+    ## Unregisters ``fd``.
+    getGlobalDispatcher().handles.excl(fd)
+
   initAll()
 else:
   import selectors
-  from posix import EINTR, EAGAIN, EINPROGRESS, EWOULDBLOCK, MSG_PEEK
+  when defined(windows):
+    import winlean
+    const
+      EINTR = WSAEINPROGRESS
+      EINPROGRESS = WSAEINPROGRESS
+      EWOULDBLOCK = WSAEWOULDBLOCK
+      EAGAIN = EINPROGRESS
+      MSG_NOSIGNAL = 0
+  else:
+    from posix import EINTR, EAGAIN, EINPROGRESS, EWOULDBLOCK, MSG_PEEK,
+                      MSG_NOSIGNAL
+  
   type
     TAsyncFD* = distinct cint
     TCallback = proc (sock: TAsyncFD): bool {.closure,gcsafe.}
@@ -577,11 +637,14 @@ else:
     result.TSocketHandle.setBlocking(false)
     register(result)
   
-  proc close*(sock: TAsyncFD) =
+  proc closeSocket*(sock: TAsyncFD) =
     let disp = getGlobalDispatcher()
     sock.TSocketHandle.close()
     disp.selector.unregister(sock.TSocketHandle)
 
+  proc unregister*(fd: TAsyncFD) =
+    getGlobalDispatcher().selector.unregister(fd.TSocketHandle)
+
   proc addRead(sock: TAsyncFD, cb: TCallback) =
     let p = getGlobalDispatcher()
     if sock.TSocketHandle notin p.selector:
@@ -667,20 +730,23 @@ else:
     return retFuture
 
   proc recv*(socket: TAsyncFD, size: int,
-             flags: int = 0): PFuture[string] =
+             flags = {TSocketFlags.SafeDisconn}): PFuture[string] =
     var retFuture = newFuture[string]()
     
     var readBuffer = newString(size)
 
     proc cb(sock: TAsyncFD): bool =
       result = true
-      let res = recv(sock.TSocketHandle, addr readBuffer[0], size,
-                     flags.cint)
+      let res = recv(sock.TSocketHandle, addr readBuffer[0], size.cint,
+                     flags.toOSFlags())
       #echo("recv cb res: ", res)
       if res < 0:
         let lastError = osLastError()
-        if lastError.int32 notin {EINTR, EWOULDBLOCK, EAGAIN}: 
-          retFuture.fail(newException(EOS, osErrorMsg(lastError)))
+        if lastError.int32 notin {EINTR, EWOULDBLOCK, EAGAIN}:
+          if flags.isDisconnectionError(lastError):
+            retFuture.complete("")
+          else:
+            retFuture.fail(newException(EOS, osErrorMsg(lastError)))
         else:
           result = false # We still want this callback to be called.
       elif res == 0:
@@ -689,11 +755,13 @@ else:
       else:
         readBuffer.setLen(res)
         retFuture.complete(readBuffer)
-  
+    # TODO: The following causes a massive slowdown.
+    #if not cb(socket):
     addRead(socket, cb)
     return retFuture
 
-  proc send*(socket: TAsyncFD, data: string): PFuture[void] =
+  proc send*(socket: TAsyncFD, data: string,
+             flags = {TSocketFlags.SafeDisconn}): PFuture[void] =
     var retFuture = newFuture[void]()
     
     var written = 0
@@ -702,11 +770,15 @@ else:
       result = true
       let netSize = data.len-written
       var d = data.cstring
-      let res = send(sock.TSocketHandle, addr d[written], netSize, 0.cint)
+      let res = send(sock.TSocketHandle, addr d[written], netSize.cint,
+                     MSG_NOSIGNAL)
       if res < 0:
         let lastError = osLastError()
         if lastError.int32 notin {EINTR, EWOULDBLOCK, EAGAIN}:
-          retFuture.fail(newException(EOS, osErrorMsg(lastError)))
+          if flags.isDisconnectionError(lastError):
+            retFuture.complete()
+          else:
+            retFuture.fail(newException(EOS, osErrorMsg(lastError)))
         else:
           result = false # We still want this callback to be called.
       else:
@@ -715,6 +787,8 @@ else:
           result = false # We still have data to send.
         else:
           retFuture.complete()
+    # TODO: The following causes crashes.
+    #if not cb(socket):
     addWrite(socket, cb)
     return retFuture
 
@@ -757,41 +831,76 @@ proc accept*(socket: TAsyncFD): PFuture[TAsyncFD] =
 
 # -- Await Macro
 
-template createCb*(retFutureSym, iteratorNameSym: expr): stmt {.immediate.} =
+template createCb*(retFutureSym, iteratorNameSym,
+                   name: expr): stmt {.immediate.} =
   var nameIterVar = iteratorNameSym
+  #{.push stackTrace: off.}
   proc cb {.closure,gcsafe.} =
-    if not nameIterVar.finished:
-      var next = nameIterVar()
-      if next == nil:
-        assert retFutureSym.finished, "Async procedure's return Future was not finished."
-      else:
-        next.callback = cb
+    try:
+      if not nameIterVar.finished:
+        var next = nameIterVar()
+        if next == nil:
+          assert retFutureSym.finished, "Async procedure's (" &
+                 name & ") return Future was not finished."
+        else:
+          next.callback = cb
+    except:
+      retFutureSym.fail(getCurrentException())
   cb()
-
-template createVar(futSymName: string, asyncProc: PNimrodNode,
-                   valueReceiver: expr) {.immediate, dirty.} =
-  # TODO: Used template here due to bug #926
+  #{.pop.}
+proc generateExceptionCheck(futSym,
+    exceptBranch, rootReceiver: PNimrodNode): PNimrodNode {.compileTime.} =
+  if exceptBranch == nil:
+    result = rootReceiver
+  else:
+    if exceptBranch[0].kind == nnkStmtList:
+      result = newIfStmt(
+        (newDotExpr(futSym, newIdentNode("failed")),
+           exceptBranch[0]
+         )
+      )
+    else:
+      expectKind(exceptBranch[1], nnkStmtList)
+      result = newIfStmt(
+        (newDotExpr(futSym, newIdentNode("failed")),
+           newIfStmt(
+             (infix(newDotExpr(futSym, newIdentNode("error")), "of", exceptBranch[0]),
+              exceptBranch[1])
+           )
+         )
+      )
+    let elseNode = newNimNode(nnkElse)
+    elseNode.add newNimNode(nnkStmtList)
+    elseNode[0].add rootReceiver
+    result.add elseNode
+
+template createVar(result: var PNimrodNode, futSymName: string,
+                   asyncProc: PNimrodNode,
+                   valueReceiver, rootReceiver: expr) =
   result = newNimNode(nnkStmtList)
   var futSym = genSym(nskVar, "future")
   result.add newVarStmt(futSym, asyncProc) # -> var future<x> = y
   result.add newNimNode(nnkYieldStmt).add(futSym) # -> yield future<x>
   valueReceiver = newDotExpr(futSym, newIdentNode("read")) # -> future<x>.read
+  result.add generateExceptionCheck(futSym, exceptBranch, rootReceiver)
 
 proc processBody(node, retFutureSym: PNimrodNode,
-                 subtypeName: string): PNimrodNode {.compileTime.} =
+                 subTypeIsVoid: bool,
+                 exceptBranch: PNimrodNode): PNimrodNode {.compileTime.} =
+  #echo(node.treeRepr)
   result = node
   case node.kind
   of nnkReturnStmt:
     result = newNimNode(nnkStmtList)
     if node[0].kind == nnkEmpty:
-      if subtypeName != "void":
+      if not subtypeIsVoid:
         result.add newCall(newIdentNode("complete"), retFutureSym,
             newIdentNode("result"))
       else:
         result.add newCall(newIdentNode("complete"), retFutureSym)
     else:
       result.add newCall(newIdentNode("complete"), retFutureSym,
-        node[0].processBody(retFutureSym, subtypeName))
+        node[0].processBody(retFutureSym, subtypeIsVoid, exceptBranch))
 
     result.add newNimNode(nnkReturnStmt).add(newNilLit())
     return # Don't process the children of this return stmt
@@ -804,16 +913,16 @@ proc processBody(node, retFutureSym: PNimrodNode,
       of nnkCall:
         # await foo(p, x)
         var futureValue: PNimrodNode
-        createVar("future" & $node[1][0].toStrLit, node[1], futureValue)
-        result.add futureValue
+        result.createVar("future" & $node[1][0].toStrLit, node[1], futureValue,
+                  futureValue)
       else:
         error("Invalid node kind in 'await', got: " & $node[1].kind)
     elif node[1].kind == nnkCommand and node[1][0].kind == nnkIdent and
          node[1][0].ident == !"await":
       # foo await x
       var newCommand = node
-      createVar("future" & $node[0].toStrLit, node[1][1], newCommand[1])
-      result.add newCommand
+      result.createVar("future" & $node[0].toStrLit, node[1][1], newCommand[1],
+                newCommand)
 
   of nnkVarSection, nnkLetSection:
     case node[0][2].kind
@@ -821,9 +930,8 @@ proc processBody(node, retFutureSym: PNimrodNode,
       if node[0][2][0].ident == !"await":
         # var x = await y
         var newVarSection = node # TODO: Should this use copyNimNode?
-        createVar("future" & $node[0][0].ident, node[0][2][1],
-          newVarSection[0][2])
-        result.add newVarSection
+        result.createVar("future" & $node[0][0].ident, node[0][2][1],
+          newVarSection[0][2], newVarSection)
     else: discard
   of nnkAsgn:
     case node[1].kind
@@ -831,19 +939,43 @@ proc processBody(node, retFutureSym: PNimrodNode,
       if node[1][0].ident == !"await":
         # x = await y
         var newAsgn = node
-        createVar("future" & $node[0].toStrLit, node[1][1], newAsgn[1])
-        result.add newAsgn
+        result.createVar("future" & $node[0].toStrLit, node[1][1], newAsgn[1], newAsgn)
     else: discard
   of nnkDiscardStmt:
     # discard await x
-    if node[0][0].kind == nnkIdent and node[0][0].ident == !"await":
-      var dummy = newNimNode(nnkStmtList)
-      createVar("futureDiscard_" & $toStrLit(node[0][1]), node[0][1], dummy)
+    if node[0].kind != nnkEmpty and node[0][0].kind == nnkIdent and
+          node[0][0].ident == !"await":
+      var newDiscard = node
+      result.createVar("futureDiscard_" & $toStrLit(node[0][1]), node[0][1],
+                newDiscard[0], newDiscard)
+  of nnkTryStmt:
+    # try: await x; except: ...
+    result = newNimNode(nnkStmtList)
+    proc processForTry(n: PNimrodNode, i: var int,
+                       res: PNimrodNode): bool {.compileTime.} =
+      result = false
+      while i < n[0].len:
+        var processed = processBody(n[0][i], retFutureSym, subtypeIsVoid, n[1])
+        if processed.kind != n[0][i].kind or processed.len != n[0][i].len:
+          expectKind(processed, nnkStmtList)
+          expectKind(processed[2][1], nnkElse)
+          i.inc
+          discard processForTry(n, i, processed[2][1][0])
+          res.add processed
+          result = true
+        else:
+          res.add n[0][i]
+          i.inc
+    var i = 0
+    if not processForTry(node, i, result):
+      var temp = node
+      temp[0] = result
+      result = temp
+    return
   else: discard
-  
+
   for i in 0 .. <result.len:
-    result[i] = processBody(result[i], retFutureSym, subtypeName)
-  #echo(treeRepr(result))
+    result[i] = processBody(result[i], retFutureSym, subtypeIsVoid, exceptBranch)
 
 proc getName(node: PNimrodNode): string {.compileTime.} =
   case node.kind
@@ -851,47 +983,53 @@ proc getName(node: PNimrodNode): string {.compileTime.} =
     return $node[1].ident
   of nnkIdent:
     return $node.ident
+  of nnkEmpty:
+    return "anonymous"
   else:
-    assert false
+    error("Unknown name.")
 
 macro async*(prc: stmt): stmt {.immediate.} =
   ## Macro which processes async procedures into the appropriate
   ## iterators and yield statements.
-
-  expectKind(prc, nnkProcDef)
+  if prc.kind notin {nnkProcDef, nnkLambda}:
+    error("Cannot transform this node kind into an async proc." &
+          " Proc definition or lambda node expected.")
 
   hint("Processing " & prc[0].getName & " as an async proc.")
 
   let returnType = prc[3][0]
-  var subtypeName = ""
   # Verify that the return type is a PFuture[T]
   if returnType.kind == nnkIdent:
     error("Expected return type of 'PFuture' got '" & $returnType & "'")
   elif returnType.kind == nnkBracketExpr:
     if $returnType[0] != "PFuture":
       error("Expected return type of 'PFuture' got '" & $returnType[0] & "'")
-    subtypeName = $returnType[1].ident
-  elif returnType.kind == nnkEmpty:
-    subtypeName = "void"
+
+  let subtypeIsVoid = returnType.kind == nnkEmpty or
+        (returnType.kind == nnkBracketExpr and
+         returnType[1].kind == nnkIdent and returnType[1].ident == !"void")
 
   var outerProcBody = newNimNode(nnkStmtList)
 
   # -> var retFuture = newFuture[T]()
   var retFutureSym = genSym(nskVar, "retFuture")
+  var subRetType =
+    if returnType.kind == nnkEmpty: newIdentNode("void")
+    else: returnType[1]
   outerProcBody.add(
     newVarStmt(retFutureSym, 
       newCall(
         newNimNode(nnkBracketExpr).add(
           newIdentNode(!"newFuture"), # TODO: Strange bug here? Remove the `!`.
-          newIdentNode(subtypeName))))) # Get type from return type of this proc
+          subRetType)))) # Get type from return type of this proc
   
   # -> iterator nameIter(): PFutureBase {.closure.} = 
   # ->   var result: T
   # ->   <proc_body>
   # ->   complete(retFuture, result)
   var iteratorNameSym = genSym(nskIterator, $prc[0].getName & "Iter")
-  var procBody = prc[6].processBody(retFutureSym, subtypeName)
-  if subtypeName != "void":
+  var procBody = prc[6].processBody(retFutureSym, subtypeIsVoid, nil)
+  if not subtypeIsVoid:
     procBody.insert(0, newNimNode(nnkVarSection).add(
       newIdentDefs(newIdentNode("result"), returnType[1]))) # -> var result: T
     procBody.add(
@@ -908,7 +1046,8 @@ macro async*(prc: stmt): stmt {.immediate.} =
 
   # -> createCb(retFuture)
   var cbName = newIdentNode("cb")
-  var procCb = newCall("createCb", retFutureSym, iteratorNameSym)
+  var procCb = newCall("createCb", retFutureSym, iteratorNameSym,
+                       newStrLitNode(prc[0].getName))
   outerProcBody.add procCb
 
   # -> return retFuture
@@ -918,17 +1057,18 @@ macro async*(prc: stmt): stmt {.immediate.} =
 
   # Remove the 'async' pragma.
   for i in 0 .. <result[4].len:
-    if result[4][i].ident == !"async":
+    if result[4][i].kind == nnkIdent and result[4][i].ident == !"async":
       result[4].del(i)
-  if subtypeName == "void":
+  if subtypeIsVoid:
     # Add discardable pragma.
-    result[4].add(newIdentNode("discardable"))
     if returnType.kind == nnkEmpty:
       # Add PFuture[void]
       result[3][0] = parseExpr("PFuture[void]")
 
   result[6] = outerProcBody
 
+  #echo(treeRepr(result))
+  #if prc[0].getName == "routeReq":
   #echo(toStrLit(result))
 
 proc recvLine*(socket: TAsyncFD): PFuture[string] {.async.} =
@@ -956,7 +1096,7 @@ proc recvLine*(socket: TAsyncFD): PFuture[string] {.async.} =
     if c.len == 0:
       return ""
     if c == "\r":
-      c = await recv(socket, 1, MSG_PEEK)
+      c = await recv(socket, 1, {TSocketFlags.SafeDisconn, TSocketFlags.Peek})
       if c.len > 0 and c == "\L":
         discard await recv(socket, 1)
       addNLIfEmpty()
diff --git a/lib/pure/asynchttpserver.nim b/lib/pure/asynchttpserver.nim
index 2ebd7036d..ee6658fd1 100644
--- a/lib/pure/asynchttpserver.nim
+++ b/lib/pure/asynchttpserver.nim
@@ -14,12 +14,13 @@
 import strtabs, asyncnet, asyncdispatch, parseutils, parseurl, strutils
 type
   TRequest* = object
-    client: PAsyncSocket # TODO: Separate this into a Response object?
+    client*: PAsyncSocket # TODO: Separate this into a Response object?
     reqMethod*: string
     headers*: PStringTable
     protocol*: tuple[orig: string, major, minor: int]
     url*: TURL
     hostname*: string ## The hostname of the client that made the request.
+    body*: string
 
   PAsyncHttpServer* = ref object
     socket: PAsyncSocket
@@ -50,10 +51,15 @@ proc `==`*(protocol: tuple[orig: string, major, minor: int],
 proc newAsyncHttpServer*(): PAsyncHttpServer =
   new result
 
-proc sendHeaders*(req: TRequest, headers: PStringTable) {.async.} =
-  ## Sends the specified headers to the requesting client.
+proc addHeaders(msg: var string, headers: PStringTable) =
   for k, v in headers:
-    await req.client.send(k & ": " & v & "\c\L")
+    msg.add(k & ": " & v & "\c\L")
+
+proc sendHeaders*(req: TRequest, headers: PStringTable): PFuture[void] =
+  ## Sends the specified headers to the requesting client.
+  var msg = ""
+  addHeaders(msg, headers)
+  return req.client.send(msg)
 
 proc respond*(req: TRequest, code: THttpCode,
         content: string, headers: PStringTable = newStringTable()) {.async.} =
@@ -63,9 +69,9 @@ proc respond*(req: TRequest, code: THttpCode,
   ## This procedure will **not** close the client socket.
   var customHeaders = headers
   customHeaders["Content-Length"] = $content.len
-  await req.client.send("HTTP/1.1 " & $code & "\c\L")
-  await sendHeaders(req, headers)
-  await req.client.send("\c\L" & content)
+  var msg = "HTTP/1.1 " & $code & "\c\L"
+  msg.addHeaders(customHeaders)
+  await req.client.send(msg & "\c\L" & content)
 
 proc newRequest(): TRequest =
   result.headers = newStringTable(modeCaseInsensitive)
@@ -77,7 +83,7 @@ proc parseHeader(line: string): tuple[key, value: string] =
   i += line.skipWhiteSpace(i)
   i += line.parseUntil(result.value, {'\c', '\L'}, i)
 
-proc parseProtocol(protocol: string):  tuple[orig: string, major, minor: int] =
+proc parseProtocol(protocol: string): tuple[orig: string, major, minor: int] =
   var i = protocol.skipIgnoreCase("HTTP/")
   if i != 5:
     raise newException(EInvalidValue, "Invalid request protocol. Got: " &
@@ -87,70 +93,95 @@ proc parseProtocol(protocol: string):  tuple[orig: string, major, minor: int] =
   i.inc # Skip .
   i.inc protocol.parseInt(result.minor, i)
 
+proc sendStatus(client: PAsyncSocket, status: string): PFuture[void] =
+  client.send("HTTP/1.1 " & status & "\c\L")
+
 proc processClient(client: PAsyncSocket, address: string,
                  callback: proc (request: TRequest): PFuture[void]) {.async.} =
-  # GET /path HTTP/1.1
-  # Header: val
-  # \n
-  var request = newRequest()
-  request.hostname = address
-  assert client != nil
-  request.client = client
-
-  # First line - GET /path HTTP/1.1
-  let line = await client.recvLine() # TODO: Timeouts.
-  if line == "":
-    client.close()
-    return
-  let lineParts = line.split(' ')
-  if lineParts.len != 3:
-    request.respond(Http400, "Invalid request. Got: " & line)
-    client.close()
-    return
-
-  let reqMethod = lineParts[0]
-  let path = lineParts[1]
-  let protocol = lineParts[2]
-
-  # Headers
-  var i = 0
   while true:
-    i = 0
-    let headerLine = await client.recvLine()
-    if headerLine == "":
-      client.close(); return
-    if headerLine == "\c\L": break
-    # TODO: Compiler crash
-    #let (key, value) = parseHeader(headerLine)
-    let kv = parseHeader(headerLine)
-    request.headers[kv.key] = kv.value
-
-  request.reqMethod = reqMethod
-  request.url = parseUrl(path)
-  try:
-    request.protocol = protocol.parseProtocol()
-  except EInvalidValue:
-    request.respond(Http400, "Invalid request protocol. Got: " & protocol)
-    return
-  
-  case reqMethod.normalize
-  of "get", "post", "head", "put", "delete", "trace", "options", "connect", "patch":
-    await callback(request)
-  else:
-    request.respond(Http400, "Invalid request method. Got: " & reqMethod)
-
-  # Persistent connections
-  if (request.protocol == HttpVer11 and
-      request.headers["connection"].normalize != "close") or
-     (request.protocol == HttpVer10 and
-      request.headers["connection"].normalize == "keep-alive"):
-    # In HTTP 1.1 we assume that connection is persistent. Unless connection
-    # header states otherwise.
-    # In HTTP 1.0 we assume that the connection should not be persistent.
-    # Unless the connection header states otherwise.
-    await processClient(client, address, callback)
-  else:
-    request.client.close()
+    # GET /path HTTP/1.1
+    # Header: val
+    # \n
+    var request = newRequest()
+    request.hostname = address
+    assert client != nil
+    request.client = client
+
+    # First line - GET /path HTTP/1.1
+    let line = await client.recvLine() # TODO: Timeouts.
+    if line == "":
+      client.close()
+      return
+    let lineParts = line.split(' ')
+    if lineParts.len != 3:
+      await request.respond(Http400, "Invalid request. Got: " & line)
+      continue
+
+    let reqMethod = lineParts[0]
+    let path = lineParts[1]
+    let protocol = lineParts[2]
+
+    # Headers
+    var i = 0
+    while true:
+      i = 0
+      let headerLine = await client.recvLine()
+      if headerLine == "":
+        client.close(); return
+      if headerLine == "\c\L": break
+      # TODO: Compiler crash
+      #let (key, value) = parseHeader(headerLine)
+      let kv = parseHeader(headerLine)
+      request.headers[kv.key] = kv.value
+
+    request.reqMethod = reqMethod
+    request.url = parseUrl(path)
+    try:
+      request.protocol = protocol.parseProtocol()
+    except EInvalidValue:
+      asyncCheck request.respond(Http400, "Invalid request protocol. Got: " &
+          protocol)
+      continue
+
+    if reqMethod.normalize == "post":
+      # Check for Expect header
+      if request.headers.hasKey("Expect"):
+        if request.headers["Expect"].toLower == "100-continue":
+          await client.sendStatus("100 Continue")
+        else:
+          await client.sendStatus("417 Expectation Failed")
+    
+      # Read the body
+      # - Check for Content-length header
+      if request.headers.hasKey("Content-Length"):
+        var contentLength = 0
+        if parseInt(request.headers["Content-Length"], contentLength) == 0:
+          await request.respond(Http400, "Bad Request. Invalid Content-Length.")
+        else:
+          request.body = await client.recv(contentLength)
+          assert request.body.len == contentLength
+      else:
+        await request.respond(Http400, "Bad Request. No Content-Length.")
+        continue
+
+    case reqMethod.normalize
+    of "get", "post", "head", "put", "delete", "trace", "options", "connect", "patch":
+      await callback(request)
+    else:
+      await request.respond(Http400, "Invalid request method. Got: " & reqMethod)
+
+    # Persistent connections
+    if (request.protocol == HttpVer11 and
+        request.headers["connection"].normalize != "close") or
+       (request.protocol == HttpVer10 and
+        request.headers["connection"].normalize == "keep-alive"):
+      # In HTTP 1.1 we assume that connection is persistent. Unless connection
+      # header states otherwise.
+      # In HTTP 1.0 we assume that the connection should not be persistent.
+      # Unless the connection header states otherwise.
+    else:
+      request.client.close()
+      break
 
 proc serve*(server: PAsyncHttpServer, port: TPort,
             callback: proc (request: TRequest): PFuture[void],
@@ -167,14 +198,20 @@ proc serve*(server: PAsyncHttpServer, port: TPort,
     # TODO: Causes compiler crash.
     #var (address, client) = await server.socket.acceptAddr()
     var fut = await server.socket.acceptAddr()
-    processClient(fut.client, fut.address, callback)
+    asyncCheck processClient(fut.client, fut.address, callback)
+
+proc close*(server: PAsyncHttpServer) =
+  ## Terminates the async http server instance.
+  server.socket.close()
 
 when isMainModule:
   var server = newAsyncHttpServer()
   proc cb(req: TRequest) {.async.} =
     #echo(req.reqMethod, " ", req.url)
     #echo(req.headers)
-    await req.respond(Http200, "Hello World")
+    let headers = {"Date": "Tue, 29 Apr 2014 23:40:08 GMT",
+        "Content-type": "text/plain; charset=utf-8"}
+    await req.respond(Http200, "Hello World", headers.newStringTable())
 
-  server.serve(TPort(5555), cb)
+  asyncCheck server.serve(TPort(5555), cb)
   runForever()
diff --git a/lib/pure/asyncnet.nim b/lib/pure/asyncnet.nim
index b1abf627b..374ac77e3 100644
--- a/lib/pure/asyncnet.nim
+++ b/lib/pure/asyncnet.nim
@@ -80,7 +80,8 @@ proc connect*(socket: PAsyncSocket, address: string, port: TPort,
   ## or an error occurs.
   result = connect(socket.fd.TAsyncFD, address, port, af)
 
-proc readIntoBuf(socket: PAsyncSocket, flags: int): PFuture[int] {.async.} =
+proc readIntoBuf(socket: PAsyncSocket,
+    flags: set[TSocketFlags]): PFuture[int] {.async.} =
   var data = await recv(socket.fd.TAsyncFD, BufferSize, flags)
   if data.len != 0:
     copyMem(addr socket.buffer[0], addr data[0], data.len)
@@ -89,7 +90,7 @@ proc readIntoBuf(socket: PAsyncSocket, flags: int): PFuture[int] {.async.} =
   result = data.len
 
 proc recv*(socket: PAsyncSocket, size: int,
-           flags: int = 0): PFuture[string] {.async.} =
+           flags = {TSocketFlags.SafeDisconn}): PFuture[string] {.async.} =
   ## Reads ``size`` bytes from ``socket``. Returned future will complete once
   ## all of the requested data is read. If socket is disconnected during the
   ## recv operation then the future may complete with only a part of the
@@ -97,37 +98,42 @@ proc recv*(socket: PAsyncSocket, size: int,
   ## to be read then the future will complete with a value of ``""``.
   if socket.isBuffered:
     result = newString(size)
-
-    template returnNow(readBytes: int) =
-      result.setLen(readBytes)
-      # Only increase buffer position when not peeking.
-      if (flags and MSG_PEEK) != MSG_PEEK:
-        socket.currPos.inc(readBytes)
-      return
+    let originalBufPos = socket.currPos
 
     if socket.bufLen == 0:
-      let res = await socket.readIntoBuf(flags and (not MSG_PEEK))
-      if res == 0: returnNow(0)
+      let res = await socket.readIntoBuf(flags - {TSocketFlags.Peek})
+      if res == 0:
+        result.setLen(0)
+        return
 
     var read = 0
     while read < size:
       if socket.currPos >= socket.bufLen:
-        let res = await socket.readIntoBuf(flags and (not MSG_PEEK))
-        if res == 0: returnNow(read)
+        if TSocketFlags.Peek in flags:
+          # We don't want to get another buffer if we're peeking.
+          break
+        let res = await socket.readIntoBuf(flags - {TSocketFlags.Peek})
+        if res == 0:
+          break
 
       let chunk = min(socket.bufLen-socket.currPos, size-read)
-      copyMem(addr(result[read]), addr(socket.buffer[socket.currPos+read]), chunk)
+      copyMem(addr(result[read]), addr(socket.buffer[socket.currPos]), chunk)
       read.inc(chunk)
+      socket.currPos.inc(chunk)
 
-    returnNow(read)
+    if TSocketFlags.Peek in flags:
+      # Restore old buffer cursor position.
+      socket.currPos = originalBufPos
+    result.setLen(read)
   else:
     result = await recv(socket.fd.TAsyncFD, size, flags)
 
-proc send*(socket: PAsyncSocket, data: string): PFuture[void] =
+proc send*(socket: PAsyncSocket, data: string,
+           flags = {TSocketFlags.SafeDisconn}): PFuture[void] =
   ## Sends ``data`` to ``socket``. The returned future will complete once all
   ## data has been sent.
   assert socket != nil
-  result = send(socket.fd.TAsyncFD, data)
+  result = send(socket.fd.TAsyncFD, data, flags)
 
 proc acceptAddr*(socket: PAsyncSocket): 
       PFuture[tuple[address: string, client: PAsyncSocket]] =
@@ -162,7 +168,8 @@ proc accept*(socket: PAsyncSocket): PFuture[PAsyncSocket] =
         retFut.complete(future.read.client)
   return retFut
 
-proc recvLine*(socket: PAsyncSocket): PFuture[string] {.async.} =
+proc recvLine*(socket: PAsyncSocket,
+    flags = {TSocketFlags.SafeDisconn}): PFuture[string] {.async.} =
   ## Reads a line of data from ``socket``. Returned future will complete once
   ## a full line is read or an error occurs.
   ##
@@ -175,28 +182,60 @@ proc recvLine*(socket: PAsyncSocket): PFuture[string] {.async.} =
   ## If the socket is disconnected in the middle of a line (before ``\r\L``
   ## is read) then line will be set to ``""``.
   ## The partial line **will be lost**.
-  
+  ##
+  ## **Warning**: The ``Peek`` flag is not yet implemented.
   template addNLIfEmpty(): stmt =
     if result.len == 0:
       result.add("\c\L")
+  assert TSocketFlags.Peek notin flags ## TODO:
+  if socket.isBuffered:
+    result = ""
+    if socket.bufLen == 0:
+      let res = await socket.readIntoBuf(flags)
+      if res == 0:
+        return
 
-  result = ""
-  var c = ""
-  while true:
-    c = await recv(socket, 1)
-    if c.len == 0:
-      return ""
-    if c == "\r":
-      c = await recv(socket, 1, MSG_PEEK)
-      if c.len > 0 and c == "\L":
-        let dummy = await recv(socket, 1)
-        assert dummy == "\L"
-      addNLIfEmpty()
-      return
-    elif c == "\L":
-      addNLIfEmpty()
-      return
-    add(result.string, c)
+    var lastR = false
+    while true:
+      if socket.currPos >= socket.bufLen:
+        let res = await socket.readIntoBuf(flags)
+        if res == 0:
+          result = ""
+          break
+
+      case socket.buffer[socket.currPos]
+      of '\r':
+        lastR = true
+        addNLIfEmpty()
+      of '\L':
+        addNLIfEmpty()
+        socket.currPos.inc()
+        return
+      else:
+        if lastR:
+          socket.currPos.inc()
+          return
+        else:
+          result.add socket.buffer[socket.currPos]
+      socket.currPos.inc()
+  else:
+    result = ""
+    var c = ""
+    while true:
+      c = await recv(socket, 1, flags)
+      if c.len == 0:
+        return ""
+      if c == "\r":
+        c = await recv(socket, 1, flags + {TSocketFlags.Peek})
+        if c.len > 0 and c == "\L":
+          let dummy = await recv(socket, 1, flags)
+          assert dummy == "\L"
+        addNLIfEmpty()
+        return
+      elif c == "\L":
+        addNLIfEmpty()
+        return
+      add(result.string, c)
 
 proc bindAddr*(socket: PAsyncSocket, port = TPort(0), address = "") =
   ## Binds ``address``:``port`` to the socket.
@@ -214,7 +253,7 @@ proc listen*(socket: PAsyncSocket, backlog = SOMAXCONN) =
 
 proc close*(socket: PAsyncSocket) =
   ## Closes the socket.
-  socket.fd.TAsyncFD.close()
+  socket.fd.TAsyncFD.closeSocket()
   # TODO SSL
 
 when isMainModule:
@@ -235,7 +274,7 @@ when isMainModule:
           break
         else:
           echo("Got line: ", line)
-    main()
+    asyncCheck main()
   elif test == LowClient:
     var sock = newAsyncSocket()
     var f = connect(sock, "irc.freenode.net", TPort(6667))
diff --git a/lib/pure/collections/sequtils.nim b/lib/pure/collections/sequtils.nim
index f5db9d3fa..e760c5e02 100644
--- a/lib/pure/collections/sequtils.nim
+++ b/lib/pure/collections/sequtils.nim
@@ -47,19 +47,15 @@ proc concat*[T](seqs: varargs[seq[T]]): seq[T] =
       result[i] = itm
       inc(i)
 
-proc distnct*[T](seq1: seq[T]): seq[T] =
+proc deduplicate*[T](seq1: seq[T]): seq[T] =
   ## Returns a new sequence without duplicates.
   ##
-  ## This proc is `misspelled` on purpose to avoid a clash with the keyword
-  ## ``distinct`` used to `define a derived type incompatible with its base
-  ## type <manual.html#distinct-type>`_. Example:
-  ##
   ## .. code-block:: nimrod
   ##   let
   ##     dup1 = @[1, 1, 3, 4, 2, 2, 8, 1, 4]
   ##     dup2 = @["a", "a", "c", "d", "d"]
-  ##     unique1 = distnct(dup1)
-  ##     unique2 = distnct(dup2)
+  ##     unique1 = deduplicate(dup1)
+  ##     unique2 = deduplicate(dup2)
   ##   assert unique1 == @[1, 3, 4, 2, 8]
   ##   assert unique2 == @["a", "c", "d"]
   result = @[]
@@ -182,6 +178,24 @@ proc filter*[T](seq1: seq[T], pred: proc(item: T): bool {.closure.}): seq[T] =
   ##   assert f2 == @["yellow"]
   accumulateResult(filter(seq1, pred))
 
+proc keepIf*[T](seq1: var seq[T], pred: proc(item: T): bool {.closure.}) =
+  ## Keeps the items in the passed sequence if they fulfilled the predicate.
+  ## Same as the ``filter`` proc, but modifies the sequence directly.
+  ##
+  ## Example:
+  ##
+  ## .. code-block:: nimrod
+  ##   var floats = @[13.0, 12.5, 5.8, 2.0, 6.1, 9.9, 10.1]
+  ##   filter(floats, proc(x: float): bool = x > 10)
+  ##   assert floats == @[13.0, 12.5, 10.1]
+  var pos = 0
+  for i in 0 .. <len(seq1):
+    if pred(seq1[i]):
+      if pos != i:
+        seq1[pos] = seq1[i]
+      inc(pos)
+  setLen(seq1, pos)
+
 proc delete*[T](s: var seq[T], first=0, last=0) =
   ## Deletes in `s` the items at position `first` .. `last`. This modifies
   ## `s` itself, it does not return a copy.
@@ -252,6 +266,27 @@ template filterIt*(seq1, pred: expr): expr {.immediate.} =
     if pred: result.add(it)
   result
 
+template keepItIf*(varSeq, pred: expr) =
+  ## Convenience template around the ``keepIf`` proc to reduce typing.
+  ##
+  ## Unlike the `proc` version, the predicate needs to be an expression using
+  ## the ``it`` variable for testing, like: ``keepItIf("abcxyz", it == 'x')``.
+  ## Example:
+  ##
+  ## .. code-block:: nimrod
+  ##   var candidates = @["foo", "bar", "baz", "foobar"]
+  ##   keepItIf(candidates, it.len == 3 and it[0] == 'b')
+  ##   assert candidates == @["bar", "baz"]
+  var pos = 0
+  for i in 0 .. <len(varSeq):
+    let it {.inject.} = varSeq[i]
+    if pred:
+      if pos != i:
+        varSeq[pos] = varSeq[i]
+      inc(pos)
+  setLen(varSeq, pos)
+
+
 template toSeq*(iter: expr): expr {.immediate.} =
   ## Transforms any iterator into a sequence.
   ##
@@ -387,8 +422,8 @@ when isMainModule:
     let
       dup1 = @[1, 1, 3, 4, 2, 2, 8, 1, 4]
       dup2 = @["a", "a", "c", "d", "d"]
-      unique1 = distnct(dup1)
-      unique2 = distnct(dup2)
+      unique1 = deduplicate(dup1)
+      unique2 = deduplicate(dup2)
     assert unique1 == @[1, 3, 4, 2, 8]
     assert unique2 == @["a", "c", "d"]
 
@@ -418,6 +453,11 @@ when isMainModule:
       echo($n)
     # echoes 4, 8, 4 in separate lines
 
+  block: # keepIf test
+    var floats = @[13.0, 12.5, 5.8, 2.0, 6.1, 9.9, 10.1]
+    keepIf(floats, proc(x: float): bool = x > 10)
+    assert floats == @[13.0, 12.5, 10.1]
+
   block: # filterIt test
     let
       temperatures = @[-272.15, -2.0, 24.5, 44.31, 99.9, -113.44]
@@ -426,6 +466,11 @@ when isMainModule:
     assert acceptable == @[-2.0, 24.5, 44.31]
     assert notAcceptable == @[-272.15, 99.9, -113.44]
 
+  block: # keepItIf test
+    var candidates = @["foo", "bar", "baz", "foobar"]
+    keepItIf(candidates, it.len == 3 and it[0] == 'b')
+    assert candidates == @["bar", "baz"]
+
   block: # toSeq test
     let
       numeric = @[1, 2, 3, 4, 5, 6, 7, 8, 9]
diff --git a/lib/pure/collections/sets.nim b/lib/pure/collections/sets.nim
index bc249ed63..4ba67cb2e 100644
--- a/lib/pure/collections/sets.nim
+++ b/lib/pure/collections/sets.nim
@@ -112,6 +112,10 @@ proc incl*[A](s: var TSet[A], key: A) =
   ## includes an element `key` in `s`.
   inclImpl()
 
+proc incl*[A](s: var TSet[A], other: TSet[A]) =
+  ## includes everything in `other` in `s`
+  for item in other: incl(s, item)
+
 proc excl*[A](s: var TSet[A], key: A) =
   ## excludes `key` from the set `s`.
   var index = rawGet(s, key)
@@ -119,6 +123,10 @@ proc excl*[A](s: var TSet[A], key: A) =
     s.data[index].slot = seDeleted
     dec(s.counter)
 
+proc excl*[A](s: var TSet[A], other: TSet[A]) =
+  ## excludes everything in `other` from `s`.
+  for item in other: excl(s, item)
+
 proc containsOrIncl*[A](s: var TSet[A], key: A): bool =
   ## returns true if `s` contains `key`, otherwise `key` is included in `s`
   ## and false is returned.
@@ -147,6 +155,43 @@ proc `$`*[A](s: TSet[A]): string =
   ## The `$` operator for hash sets.
   dollarImpl()
 
+proc union*[A](s1, s2: TSet[A]): TSet[A] =
+  ## returns a new set of all items that are contained in at
+  ## least one of `s1` and `s2`
+  result = s1
+  incl(result, s2)
+
+proc intersection*[A](s1, s2: TSet[A]): TSet[A] =
+  ## returns a new set of all items that are contained in both `s1` and `s2`
+  result = initSet[A](min(s1.data.len, s2.data.len))
+  for item in s1:
+    if item in s2: incl(result, item)
+
+proc symmetricDifference*[A](s1, s2: TSet[A]): TSet[A] =
+  ## returns a new set of all items that are contained in either
+  ## `s1` or `s2`, but not both
+  result = s1
+  for item in s2:
+    if containsOrIncl(result, item): excl(result, item)
+
+proc `+`*[A](s1, s2: TSet[A]): TSet[A] {.inline.} =
+  ## alias for `union`
+  result = union(s1, s2)
+
+proc `*`*[A](s1, s2: TSet[A]): TSet[A] {.inline.} =
+  ## alias for `intersection`
+  result = intersection(s1, s2)
+
+proc `-+-`*[A](s1, s2: TSet[A]): TSet[A] {.inline.} =
+  ## alias for `symmetricDifference`
+  result = symmetricDifference(s1, s2)
+
+proc disjoint*[A](s1, s2: TSet[A]): bool =
+  ## returns true iff `s1` and `s2` have no items in common
+  for item in s1:
+    if item in s2: return false
+  return true
+
 # ------------------------------ ordered set ------------------------------
 
 type
@@ -211,6 +256,10 @@ proc incl*[A](s: var TOrderedSet[A], key: A) =
   ## includes an element `key` in `s`.
   inclImpl()
 
+proc incl*[A](s: var TSet[A], other: TOrderedSet[A]) =
+  ## includes everything in `other` in `s`
+  for item in other: incl(s, item)
+
 proc containsOrIncl*[A](s: var TOrderedSet[A], key: A): bool =
   ## returns true if `s` contains `key`, otherwise `key` is included in `s`
   ## and false is returned.
diff --git a/lib/pure/collections/tables.nim b/lib/pure/collections/tables.nim
index cd28f9af0..ce9df09e1 100644
--- a/lib/pure/collections/tables.nim
+++ b/lib/pure/collections/tables.nim
@@ -10,6 +10,48 @@
 ## The ``tables`` module implements an efficient hash table that is
 ## a mapping from keys to values.
 ##
+## If you are using simple standard types like ``int`` or ``string`` for the
+## keys of the table you won't have any problems, but as soon as you try to use
+## a more complex object as a key you will be greeted by a strange compiler
+## error::
+##
+##   Error: type mismatch: got (Person)
+##   but expected one of:
+##   hashes.hash(x: openarray[A]): THash
+##   hashes.hash(x: int): THash
+##   hashes.hash(x: float): THash
+##   …
+##
+## What is happening here is that the types used for table keys require to have
+## a ``hash()`` proc which will convert them to a `THash <hashes.html#THash>`_
+## value, and the compiler is listing all the hash functions it knows. After
+## you add such a proc for your custom type everything will work. See this
+## example:
+##
+## .. code-block:: nimrod
+##   type
+##     Person = object
+##       firstName, lastName: string
+##
+##   proc hash(x: Person): THash =
+##     ## Piggyback on the already available string hash proc.
+##     ##
+##     ## Without this proc nothing works!
+##     result = x.firstName.hash !& x.lastName.hash
+##     result = !$result
+##
+##   var
+##     salaries = initTable[Person, int]()
+##     p1, p2: Person
+##
+##   p1.firstName = "Jon"
+##   p1.lastName = "Ross"
+##   salaries[p1] = 30_000
+##
+##   p2.firstName = "소진"
+##   p2.lastName = "ë°•"
+##   salaries[p2] = 45_000
+##
 ## **Note:** The data types declared here have *value semantics*: This means
 ## that ``=`` performs a copy of the hash table.
 
@@ -25,6 +67,7 @@ type
   TTable* {.final, myShallow.}[A, B] = object ## generic hash table
     data: TKeyValuePairSeq[A, B]
     counter: int
+  PTable*[A,B] = ref TTable[A, B]
 
 when not defined(nimhygiene):
   {.pragma: dirty.}
@@ -103,6 +146,14 @@ proc mget*[A, B](t: var TTable[A, B], key: A): var B =
   if index >= 0: result = t.data[index].val
   else: raise newException(EInvalidKey, "key not found: " & $key)
 
+iterator allValues*[A, B](t: TTable[A, B]; key: A): B =
+  ## iterates over any value in the table `t` that belongs to the given `key`.
+  var h: THash = hash(key) and high(t.data)
+  while t.data[h].slot != seEmpty:
+    if t.data[h].key == key and t.data[h].slot == seFilled:
+      yield t.data[h].val
+    h = nextTry(h, high(t.data))
+
 proc hasKey*[A, B](t: TTable[A, B], key: A): bool =
   ## returns true iff `key` is in the table `t`.
   result = rawGet(t, key) >= 0
@@ -190,7 +241,7 @@ proc `$`*[A, B](t: TTable[A, B]): string =
   ## The `$` operator for hash tables.
   dollarImpl()
   
-proc `==`*[A, B](s, t: TTable[A, B]): bool =
+template equalsImpl() =
   if s.counter == t.counter:
     # different insertion orders mean different 'data' seqs, so we have
     # to use the slow route here:
@@ -199,6 +250,9 @@ proc `==`*[A, B](s, t: TTable[A, B]): bool =
       if t[key] != val: return false
     return true
   
+proc `==`*[A, B](s, t: TTable[A, B]): bool =
+  equalsImpl()
+  
 proc indexBy*[A, B, C](collection: A, index: proc(x: B): C): TTable[C, B] =
   ## Index the collection with the proc provided.
   # TODO: As soon as supported, change collection: A to collection: A[B]
@@ -206,6 +260,87 @@ proc indexBy*[A, B, C](collection: A, index: proc(x: B): C): TTable[C, B] =
   for item in collection:
     result[index(item)] = item
 
+proc len*[A, B](t: PTable[A, B]): int =
+  ## returns the number of keys in `t`.
+  result = t.counter
+
+iterator pairs*[A, B](t: PTable[A, B]): tuple[key: A, val: B] =
+  ## iterates over any (key, value) pair in the table `t`.
+  for h in 0..high(t.data):
+    if t.data[h].slot == seFilled: yield (t.data[h].key, t.data[h].val)
+
+iterator mpairs*[A, B](t: PTable[A, B]): tuple[key: A, val: var B] =
+  ## iterates over any (key, value) pair in the table `t`. The values
+  ## can be modified.
+  for h in 0..high(t.data):
+    if t.data[h].slot == seFilled: yield (t.data[h].key, t.data[h].val)
+
+iterator keys*[A, B](t: PTable[A, B]): A =
+  ## iterates over any key in the table `t`.
+  for h in 0..high(t.data):
+    if t.data[h].slot == seFilled: yield t.data[h].key
+
+iterator values*[A, B](t: PTable[A, B]): B =
+  ## iterates over any value in the table `t`.
+  for h in 0..high(t.data):
+    if t.data[h].slot == seFilled: yield t.data[h].val
+
+iterator mvalues*[A, B](t: PTable[A, B]): var B =
+  ## iterates over any value in the table `t`. The values can be modified.
+  for h in 0..high(t.data):
+    if t.data[h].slot == seFilled: yield t.data[h].val
+
+proc `[]`*[A, B](t: PTable[A, B], key: A): B =
+  ## retrieves the value at ``t[key]``. If `key` is not in `t`,
+  ## default empty value for the type `B` is returned
+  ## and no exception is raised. One can check with ``hasKey`` whether the key
+  ## exists.
+  result = t[][key]
+
+proc mget*[A, B](t: PTable[A, B], key: A): var B =
+  ## retrieves the value at ``t[key]``. The value can be modified.
+  ## If `key` is not in `t`, the ``EInvalidKey`` exception is raised.
+  t[].mget(key)
+
+proc hasKey*[A, B](t: PTable[A, B], key: A): bool =
+  ## returns true iff `key` is in the table `t`.
+  result = t[].hasKey(key)
+
+proc `[]=`*[A, B](t: PTable[A, B], key: A, val: B) =
+  ## puts a (key, value)-pair into `t`.
+  t[][key] = val
+
+proc add*[A, B](t: PTable[A, B], key: A, val: B) =
+  ## puts a new (key, value)-pair into `t` even if ``t[key]`` already exists.
+  t[].add(key, val)
+  
+proc del*[A, B](t: PTable[A, B], key: A) =
+  ## deletes `key` from hash table `t`.
+  t[].del(key)
+
+proc newTable*[A, B](initialSize=64): PTable[A, B] =
+  new(result)
+  result[] = initTable[A, B](initialSize)
+
+proc newTable*[A, B](pairs: openArray[tuple[key: A, val: B]]): PTable[A, B] =
+  ## creates a new hash table that contains the given `pairs`.
+  new(result)
+  result[] = toTable[A, B](pairs)
+
+proc `$`*[A, B](t: PTable[A, B]): string =
+  ## The `$` operator for hash tables.
+  dollarImpl()
+
+proc `==`*[A, B](s, t: PTable[A, B]): bool =
+  equalsImpl()
+
+proc newTableFrom*[A, B, C](collection: A, index: proc(x: B): C): PTable[C, B] =
+  ## Index the collection with the proc provided.
+  # TODO: As soon as supported, change collection: A to collection: A[B]
+  result = newTable[C, B]()
+  for item in collection:
+    result[index(item)] = item
+
 # ------------------------------ ordered table ------------------------------
 
 type
@@ -216,6 +351,7 @@ type
       final, myShallow.}[A, B] = object ## table that remembers insertion order
     data: TOrderedKeyValuePairSeq[A, B]
     counter, first, last: int
+  POrderedTable*[A, B] = ref TOrderedTable[A, B]
 
 proc len*[A, B](t: TOrderedTable[A, B]): int {.inline.} =
   ## returns the number of keys in `t`.
@@ -376,6 +512,96 @@ proc sort*[A, B](t: var TOrderedTable[A, B],
   t.first = list
   t.last = tail
 
+proc len*[A, B](t: POrderedTable[A, B]): int {.inline.} =
+  ## returns the number of keys in `t`.
+  result = t.counter
+
+template forAllOrderedPairs(yieldStmt: stmt) {.dirty, immediate.} =
+  var h = t.first
+  while h >= 0:
+    var nxt = t.data[h].next
+    if t.data[h].slot == seFilled: yieldStmt
+    h = nxt
+
+iterator pairs*[A, B](t: POrderedTable[A, B]): tuple[key: A, val: B] =
+  ## iterates over any (key, value) pair in the table `t` in insertion
+  ## order.
+  forAllOrderedPairs:
+    yield (t.data[h].key, t.data[h].val)
+
+iterator mpairs*[A, B](t: POrderedTable[A, B]): tuple[key: A, val: var B] =
+  ## iterates over any (key, value) pair in the table `t` in insertion
+  ## order. The values can be modified.
+  forAllOrderedPairs:
+    yield (t.data[h].key, t.data[h].val)
+
+iterator keys*[A, B](t: POrderedTable[A, B]): A =
+  ## iterates over any key in the table `t` in insertion order.
+  forAllOrderedPairs:
+    yield t.data[h].key
+
+iterator values*[A, B](t: POrderedTable[A, B]): B =
+  ## iterates over any value in the table `t` in insertion order.
+  forAllOrderedPairs:
+    yield t.data[h].val
+
+iterator mvalues*[A, B](t: POrderedTable[A, B]): var B =
+  ## iterates over any value in the table `t` in insertion order. The values
+  ## can be modified.
+  forAllOrderedPairs:
+    yield t.data[h].val
+
+proc `[]`*[A, B](t: POrderedTable[A, B], key: A): B =
+  ## retrieves the value at ``t[key]``. If `key` is not in `t`,
+  ## default empty value for the type `B` is returned
+  ## and no exception is raised. One can check with ``hasKey`` whether the key
+  ## exists.
+  result = t[][key]
+
+proc mget*[A, B](t: POrderedTable[A, B], key: A): var B =
+  ## retrieves the value at ``t[key]``. The value can be modified.
+  ## If `key` is not in `t`, the ``EInvalidKey`` exception is raised.
+  result = t[].mget(key)
+
+proc hasKey*[A, B](t: POrderedTable[A, B], key: A): bool =
+  ## returns true iff `key` is in the table `t`.
+  result = t[].hasKey(key)
+
+proc `[]=`*[A, B](t: POrderedTable[A, B], key: A, val: B) =
+  ## puts a (key, value)-pair into `t`.
+  t[][key] = val
+
+proc add*[A, B](t: POrderedTable[A, B], key: A, val: B) =
+  ## puts a new (key, value)-pair into `t` even if ``t[key]`` already exists.
+  t[].add(key, val)
+
+proc newOrderedTable*[A, B](initialSize=64): POrderedTable[A, B] =
+  ## creates a new ordered hash table that is empty.
+  ##
+  ## `initialSize` needs to be a power of two. If you need to accept runtime
+  ## values for this you could use the ``nextPowerOfTwo`` proc from the
+  ## `math <math.html>`_ module.
+  new(result)
+  result[] = initOrderedTable[A, B]()
+
+proc newOrderedTable*[A, B](pairs: openArray[tuple[key: A, 
+                           val: B]]): POrderedTable[A, B] =
+  ## creates a new ordered hash table that contains the given `pairs`.
+  result = newOrderedTable[A, B](nextPowerOfTwo(pairs.len+10))
+  for key, val in items(pairs): result[key] = val
+
+proc `$`*[A, B](t: POrderedTable[A, B]): string =
+  ## The `$` operator for ordered hash tables.
+  dollarImpl()
+
+proc sort*[A, B](t: POrderedTable[A, B], 
+                 cmp: proc (x,y: tuple[key: A, val: B]): int) =
+  ## sorts `t` according to `cmp`. This modifies the internal list
+  ## that kept the insertion order, so insertion order is lost after this
+  ## call but key lookup and insertions remain possible after `sort` (in
+  ## contrast to the `sort` for count tables).
+  t[].sort(cmp)
+
 # ------------------------------ count tables -------------------------------
 
 type
@@ -383,6 +609,7 @@ type
       A] = object ## table that counts the number of each key
     data: seq[tuple[key: A, val: int]]
     counter: int
+  PCountTable*[A] = ref TCountTable[A]
 
 proc len*[A](t: TCountTable[A]): int =
   ## returns the number of keys in `t`.
@@ -526,3 +753,118 @@ proc sort*[A](t: var TCountTable[A]) =
         if j < h: break
     if h == 1: break
 
+proc len*[A](t: PCountTable[A]): int =
+  ## returns the number of keys in `t`.
+  result = t.counter
+
+iterator pairs*[A](t: PCountTable[A]): tuple[key: A, val: int] =
+  ## iterates over any (key, value) pair in the table `t`.
+  for h in 0..high(t.data):
+    if t.data[h].val != 0: yield (t.data[h].key, t.data[h].val)
+
+iterator mpairs*[A](t: PCountTable[A]): tuple[key: A, val: var int] =
+  ## iterates over any (key, value) pair in the table `t`. The values can
+  ## be modified.
+  for h in 0..high(t.data):
+    if t.data[h].val != 0: yield (t.data[h].key, t.data[h].val)
+
+iterator keys*[A](t: PCountTable[A]): A =
+  ## iterates over any key in the table `t`.
+  for h in 0..high(t.data):
+    if t.data[h].val != 0: yield t.data[h].key
+
+iterator values*[A](t: PCountTable[A]): int =
+  ## iterates over any value in the table `t`.
+  for h in 0..high(t.data):
+    if t.data[h].val != 0: yield t.data[h].val
+
+iterator mvalues*[A](t: PCountTable[A]): var int =
+  ## iterates over any value in the table `t`. The values can be modified.
+  for h in 0..high(t.data):
+    if t.data[h].val != 0: yield t.data[h].val
+
+proc `[]`*[A](t: PCountTable[A], key: A): int =
+  ## retrieves the value at ``t[key]``. If `key` is not in `t`,
+  ## 0 is returned. One can check with ``hasKey`` whether the key
+  ## exists.
+  result = t[][key]
+
+proc mget*[A](t: PCountTable[A], key: A): var int =
+  ## retrieves the value at ``t[key]``. The value can be modified.
+  ## If `key` is not in `t`, the ``EInvalidKey`` exception is raised.
+  result = t[].mget(key)
+
+proc hasKey*[A](t: PCountTable[A], key: A): bool =
+  ## returns true iff `key` is in the table `t`.
+  result = t[].hasKey(key)
+
+proc `[]=`*[A](t: PCountTable[A], key: A, val: int) =
+  ## puts a (key, value)-pair into `t`. `val` has to be positive.
+  assert val > 0
+  t[][key] = val
+
+proc newCountTable*[A](initialSize=64): PCountTable[A] =
+  ## creates a new count table that is empty.
+  ##
+  ## `initialSize` needs to be a power of two. If you need to accept runtime
+  ## values for this you could use the ``nextPowerOfTwo`` proc from the
+  ## `math <math.html>`_ module.
+  new(result)
+  result[] = initCountTable[A](initialSize)
+
+proc newCountTable*[A](keys: openArray[A]): PCountTable[A] =
+  ## creates a new count table with every key in `keys` having a count of 1.
+  result = newCountTable[A](nextPowerOfTwo(keys.len+10))
+  for key in items(keys): result[key] = 1
+
+proc `$`*[A](t: PCountTable[A]): string =
+  ## The `$` operator for count tables.
+  dollarImpl()
+
+proc inc*[A](t: PCountTable[A], key: A, val = 1) = 
+  ## increments `t[key]` by `val`.
+  t[].inc(key, val)
+
+proc smallest*[A](t: PCountTable[A]): tuple[key: A, val: int] =
+  ## returns the largest (key,val)-pair. Efficiency: O(n)
+  t[].smallest
+
+proc largest*[A](t: PCountTable[A]): tuple[key: A, val: int] =
+  ## returns the (key,val)-pair with the largest `val`. Efficiency: O(n)
+  t[].largest
+
+proc sort*[A](t: PCountTable[A]) =
+  ## sorts the count table so that the entry with the highest counter comes
+  ## first. This is destructive! You must not modify `t` afterwards!
+  ## You can use the iterators `pairs`,  `keys`, and `values` to iterate over
+  ## `t` in the sorted order.
+  t[].sort
+
+when isMainModule:
+  type
+    Person = object
+      firstName, lastName: string
+
+  proc hash(x: Person): THash =
+    ## Piggyback on the already available string hash proc.
+    ##
+    ## Without this proc nothing works!
+    result = x.firstName.hash !& x.lastName.hash
+    result = !$result
+
+  var
+    salaries = initTable[Person, int]()
+    p1, p2: Person
+  p1.firstName = "Jon"
+  p1.lastName = "Ross"
+  salaries[p1] = 30_000
+  p2.firstName = "소진"
+  p2.lastName = "ë°•"
+  salaries[p2] = 45_000
+  var
+    s2 = initOrderedTable[Person, int]()
+    s3 = initCountTable[Person]()
+  s2[p1] = 30_000
+  s2[p2] = 45_000
+  s3[p1] = 30_000
+  s3[p2] = 45_000
diff --git a/lib/pure/concurrency/cpuinfo.nim b/lib/pure/concurrency/cpuinfo.nim
new file mode 100644
index 000000000..dfa819f64
--- /dev/null
+++ b/lib/pure/concurrency/cpuinfo.nim
@@ -0,0 +1,58 @@
+#
+#
+#            Nimrod's Runtime Library
+#        (c) Copyright 2014 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module implements procs to determine the number of CPUs / cores.
+
+include "system/inclrtl"
+
+import strutils, os
+
+when not defined(windows):
+  import posix
+
+when defined(linux):
+  import linux
+
+when defined(macosx) or defined(bsd):
+  const
+    CTL_HW = 6
+    HW_AVAILCPU = 25
+    HW_NCPU = 3
+  proc sysctl(x: ptr array[0..3, cint], y: cint, z: pointer,
+              a: var csize, b: pointer, c: int): cint {.
+             importc: "sysctl", header: "<sys/sysctl.h>".}
+
+proc countProcessors*(): int {.rtl, extern: "ncpi$1".} =
+  ## returns the numer of the processors/cores the machine has.
+  ## Returns 0 if it cannot be detected.
+  when defined(windows):
+    var x = getEnv("NUMBER_OF_PROCESSORS")
+    if x.len > 0: result = parseInt(x.string)
+  elif defined(macosx) or defined(bsd):
+    var
+      mib: array[0..3, cint]
+      numCPU: int
+      len: csize
+    mib[0] = CTL_HW
+    mib[1] = HW_AVAILCPU
+    len = sizeof(numCPU)
+    discard sysctl(addr(mib), 2, addr(numCPU), len, nil, 0)
+    if numCPU < 1:
+      mib[1] = HW_NCPU
+      discard sysctl(addr(mib), 2, addr(numCPU), len, nil, 0)
+    result = numCPU
+  elif defined(hpux):
+    result = mpctl(MPC_GETNUMSPUS, nil, nil)
+  elif defined(irix):
+    var SC_NPROC_ONLN {.importc: "_SC_NPROC_ONLN", header: "<unistd.h>".}: cint
+    result = sysconf(SC_NPROC_ONLN)
+  else:
+    result = sysconf(SC_NPROCESSORS_ONLN)
+  if result <= 0: result = 1
+
diff --git a/lib/pure/concurrency/cpuload.nim b/lib/pure/concurrency/cpuload.nim
new file mode 100644
index 000000000..3cf6a7392
--- /dev/null
+++ b/lib/pure/concurrency/cpuload.nim
@@ -0,0 +1,96 @@
+#
+#
+#            Nimrod's Runtime Library
+#        (c) Copyright 2014 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module implements a helper for a thread pool to determine whether
+## creating a thread is a good idea.
+
+when defined(windows):
+  import winlean, os, strutils, math
+
+  proc `-`(a, b: TFILETIME): int64 = a.rdFileTime - b.rdFileTime
+elif defined(linux):
+  from cpuinfo import countProcessors
+
+type
+  ThreadPoolAdvice* = enum
+    doNothing,
+    doCreateThread,  # create additional thread for throughput
+    doShutdownThread # too many threads are busy, shutdown one
+
+  ThreadPoolState* = object
+    when defined(windows):
+      prevSysKernel, prevSysUser, prevProcKernel, prevProcUser: TFILETIME
+    calls*: int
+
+proc advice*(s: var ThreadPoolState): ThreadPoolAdvice =
+  when defined(windows):
+    var
+      sysIdle, sysKernel, sysUser,
+        procCreation, procExit, procKernel, procUser: TFILETIME
+    if getSystemTimes(sysIdle, sysKernel, sysUser) == 0 or
+        getProcessTimes(THandle(-1), procCreation, procExit, 
+                        procKernel, procUser) == 0:
+      return doNothing
+    if s.calls > 0:
+      let
+        sysKernelDiff = sysKernel - s.prevSysKernel
+        sysUserDiff = sysUser - s.prevSysUser
+
+        procKernelDiff = procKernel - s.prevProcKernel
+        procUserDiff = procUser - s.prevProcUser
+
+        sysTotal = int(sysKernelDiff + sysUserDiff)
+        procTotal = int(procKernelDiff + procUserDiff)
+      # total CPU usage < 85% --> create a new worker thread.
+      # Measurements show that 100% and often even 90% is not reached even
+      # if all my cores are busy.
+      if sysTotal == 0 or procTotal / sysTotal < 0.85:
+        result = doCreateThread
+    s.prevSysKernel = sysKernel
+    s.prevSysUser = sysUser
+    s.prevProcKernel = procKernel
+    s.prevProcUser = procUser
+  elif defined(linux):
+    proc fscanf(c: TFile, frmt: cstring) {.varargs, importc, 
+      header: "<stdio.h>".}
+
+    var f = open("/proc/loadavg")
+    var b: float
+    var busy, total: int
+    fscanf(f,"%lf %lf %lf %ld/%ld",
+           addr b, addr b, addr b, addr busy, addr total)
+    f.close()
+    let cpus = countProcessors()
+    if busy-1 < cpus:
+      result = doCreateThread
+    elif busy-1 >= cpus*2:
+      result = doShutdownThread
+    else:
+      result = doNothing
+  else:
+    # XXX implement this for other OSes
+    result = doNothing
+  inc s.calls
+
+when isMainModule:
+  proc busyLoop() =
+    while true:
+      discard random(80)
+      os.sleep(100)
+
+  spawn busyLoop()
+  spawn busyLoop()
+  spawn busyLoop()
+  spawn busyLoop()
+
+  var s: ThreadPoolState
+
+  for i in 1 .. 70:
+    echo advice(s)
+    os.sleep(1000)
diff --git a/lib/pure/concurrency/threadpool.nim b/lib/pure/concurrency/threadpool.nim
new file mode 100644
index 000000000..fd1041918
--- /dev/null
+++ b/lib/pure/concurrency/threadpool.nim
@@ -0,0 +1,378 @@
+#
+#
+#            Nimrod's Runtime Library
+#        (c) Copyright 2014 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## Implements Nimrod's 'spawn'.
+
+import cpuinfo, cpuload, locks
+
+{.push stackTrace:off.}
+
+type
+  CondVar = object
+    c: TCond
+    L: TLock
+    counter: int
+
+proc createCondVar(): CondVar =
+  initCond(result.c)
+  initLock(result.L)
+
+proc destroyCondVar(cv: var CondVar) {.inline.} =
+  deinitCond(cv.c)
+  deinitLock(cv.L)
+
+proc await(cv: var CondVar) =
+  acquire(cv.L)
+  while cv.counter <= 0:
+    wait(cv.c, cv.L)
+  dec cv.counter
+  release(cv.L)
+
+proc signal(cv: var CondVar) =
+  acquire(cv.L)
+  inc cv.counter
+  release(cv.L)
+  signal(cv.c)
+
+const CacheLineSize = 32 # true for most archs
+
+type
+  Barrier {.compilerProc.} = object
+    entered: int
+    cv: CondVar # condvar takes 3 words at least
+    when sizeof(int) < 8:
+      cacheAlign: array[CacheLineSize-4*sizeof(int), byte]
+    left: int
+    cacheAlign2: array[CacheLineSize-sizeof(int), byte]
+    interest: bool ## wether the master is interested in the "all done" event
+
+proc barrierEnter(b: ptr Barrier) {.compilerProc, inline.} =
+  # due to the signaling between threads, it is ensured we are the only
+  # one with access to 'entered' so we don't need 'atomicInc' here:
+  inc b.entered
+  # also we need no 'fence' instructions here as soon 'nimArgsPassingDone'
+  # will be called which already will perform a fence for us.
+
+proc barrierLeave(b: ptr Barrier) {.compilerProc, inline.} =
+  atomicInc b.left
+  when not defined(x86): fence()
+  if b.interest and b.left == b.entered: signal(b.cv)
+
+proc openBarrier(b: ptr Barrier) {.compilerProc, inline.} =
+  b.entered = 0
+  b.left = 0
+  b.interest = false
+
+proc closeBarrier(b: ptr Barrier) {.compilerProc.} =
+  fence()
+  if b.left != b.entered:
+    b.cv = createCondVar()
+    fence()
+    b.interest = true
+    fence()
+    while b.left != b.entered: await(b.cv)
+    destroyCondVar(b.cv)
+
+{.pop.}
+
+# ----------------------------------------------------------------------------
+
+type
+  foreign* = object ## a region that indicates the pointer comes from a
+                    ## foreign thread heap.
+  AwaitInfo = object
+    cv: CondVar
+    idx: int
+
+  FlowVarBase* = ref FlowVarBaseObj ## untyped base class for 'FlowVar[T]'
+  FlowVarBaseObj = object of TObject
+    ready, usesCondVar: bool
+    cv: CondVar #\
+    # for 'awaitAny' support
+    ai: ptr AwaitInfo
+    idx: int
+    data: pointer  # we incRef and unref it to keep it alive
+    owner: pointer # ptr Worker
+
+  FlowVarObj[T] = object of FlowVarBaseObj
+    blob: T
+
+  FlowVar*{.compilerProc.}[T] = ref FlowVarObj[T] ## a data flow variable
+
+  ToFreeQueue = object
+    len: int
+    lock: TLock
+    empty: TCond
+    data: array[512, pointer]
+
+  WorkerProc = proc (thread, args: pointer) {.nimcall, gcsafe.}
+  Worker = object
+    taskArrived: CondVar
+    taskStarted: CondVar #\
+    # task data:
+    f: WorkerProc
+    data: pointer
+    ready: bool # put it here for correct alignment!
+    initialized: bool # whether it has even been initialized
+    shutdown: bool # the pool requests to shut down this worker thread
+    q: ToFreeQueue
+
+proc await*(fv: FlowVarBase) =
+  ## waits until the value for the flowVar arrives. Usually it is not necessary
+  ## to call this explicitly.
+  if fv.usesCondVar:
+    fv.usesCondVar = false
+    await(fv.cv)
+    destroyCondVar(fv.cv)
+
+proc finished(fv: FlowVarBase) =
+  doAssert fv.ai.isNil, "flowVar is still attached to an 'awaitAny'"
+  # we have to protect against the rare cases where the owner of the flowVar
+  # simply disregards the flowVar and yet the "flowVarr" has not yet written
+  # anything to it:
+  await(fv)
+  if fv.data.isNil: return
+  let owner = cast[ptr Worker](fv.owner)
+  let q = addr(owner.q)
+  var waited = false
+  while true:
+    acquire(q.lock)
+    if q.len < q.data.len:
+      q.data[q.len] = fv.data
+      inc q.len
+      release(q.lock)
+      break
+    else:
+      # the queue is exhausted! We block until it has been cleaned:
+      release(q.lock)
+      wait(q.empty, q.lock)
+      waited = true
+  fv.data = nil
+  # wakeup other potentially waiting threads:
+  if waited: signal(q.empty)
+
+proc cleanFlowVars(w: ptr Worker) =
+  let q = addr(w.q)
+  acquire(q.lock)
+  for i in 0 .. <q.len:
+    GC_unref(cast[PObject](q.data[i]))
+  q.len = 0
+  release(q.lock)
+  signal(q.empty)
+
+proc fvFinalizer[T](fv: FlowVar[T]) = finished(fv)
+
+proc nimCreateFlowVar[T](): FlowVar[T] {.compilerProc.} =
+  new(result, fvFinalizer)
+
+proc nimFlowVarCreateCondVar(fv: FlowVarBase) {.compilerProc.} =
+  fv.cv = createCondVar()
+  fv.usesCondVar = true
+
+proc nimFlowVarSignal(fv: FlowVarBase) {.compilerProc.} =
+  if fv.ai != nil:
+    acquire(fv.ai.cv.L)
+    fv.ai.idx = fv.idx
+    inc fv.ai.cv.counter
+    release(fv.ai.cv.L)
+    signal(fv.ai.cv.c)
+  if fv.usesCondVar: signal(fv.cv)
+
+proc awaitAndThen*[T](fv: FlowVar[T]; action: proc (x: T) {.closure.}) =
+  ## blocks until the ``fv`` is available and then passes its value
+  ## to ``action``. Note that due to Nimrod's parameter passing semantics this
+  ## means that ``T`` doesn't need to be copied and so ``awaitAndThen`` can
+  ## sometimes be more efficient than ``^``.
+  await(fv)
+  when T is string or T is seq:
+    action(cast[T](fv.data))
+  elif T is ref:
+    {.error: "'awaitAndThen' not available for FlowVar[ref]".}
+  else:
+    action(fv.blob)
+  finished(fv)
+
+proc `^`*[T](fv: FlowVar[ref T]): foreign ptr T =
+  ## blocks until the value is available and then returns this value.
+  await(fv)
+  result = cast[foreign ptr T](fv.data)
+
+proc `^`*[T](fv: FlowVar[T]): T =
+  ## blocks until the value is available and then returns this value.
+  await(fv)
+  when T is string or T is seq:
+    result = cast[T](fv.data)
+  else:
+    result = fv.blob
+
+proc awaitAny*(flowVars: openArray[FlowVarBase]): int =
+  ## awaits any of the given flowVars. Returns the index of one flowVar for
+  ## which a value arrived. A flowVar only supports one call to 'awaitAny' at
+  ## the same time. That means if you await([a,b]) and await([b,c]) the second
+  ## call will only await 'c'. If there is no flowVar left to be able to wait
+  ## on, -1 is returned.
+  ## **Note**: This results in non-deterministic behaviour and so should be
+  ## avoided.
+  var ai: AwaitInfo
+  ai.cv = createCondVar()
+  var conflicts = 0
+  for i in 0 .. flowVars.high:
+    if cas(addr flowVars[i].ai, nil, addr ai):
+      flowVars[i].idx = i
+    else:
+      inc conflicts
+  if conflicts < flowVars.len:
+    await(ai.cv)
+    result = ai.idx
+    for i in 0 .. flowVars.high:
+      discard cas(addr flowVars[i].ai, addr ai, nil)
+  else:
+    result = -1
+  destroyCondVar(ai.cv)
+
+proc nimArgsPassingDone(p: pointer) {.compilerProc.} =
+  let w = cast[ptr Worker](p)
+  signal(w.taskStarted)
+
+const
+  MaxThreadPoolSize* = 256 ## maximal size of the thread pool. 256 threads
+                           ## should be good enough for anybody ;-)
+
+var
+  currentPoolSize: int
+  maxPoolSize = MaxThreadPoolSize
+  minPoolSize = 4
+  gSomeReady = createCondVar()
+  readyWorker: ptr Worker
+
+proc slave(w: ptr Worker) {.thread.} =
+  while true:
+    w.ready = true
+    readyWorker = w
+    signal(gSomeReady)
+    await(w.taskArrived)
+    assert(not w.ready)
+    w.f(w, w.data)
+    if w.q.len != 0: w.cleanFlowVars
+    if w.shutdown:
+      w.shutdown = false
+      atomicDec currentPoolSize
+
+proc setMinPoolSize*(size: range[1..MaxThreadPoolSize]) =
+  ## sets the minimal thread pool size. The default value of this is 4.
+  minPoolSize = size
+
+proc setMaxPoolSize*(size: range[1..MaxThreadPoolSize]) =
+  ## sets the minimal thread pool size. The default value of this
+  ## is ``MaxThreadPoolSize``.
+  maxPoolSize = size
+
+var
+  workers: array[MaxThreadPoolSize, TThread[ptr Worker]]
+  workersData: array[MaxThreadPoolSize, Worker]
+
+proc activateThread(i: int) {.noinline.} =
+  workersData[i].taskArrived = createCondVar()
+  workersData[i].taskStarted = createCondVar()
+  workersData[i].initialized = true
+  initCond(workersData[i].q.empty)
+  initLock(workersData[i].q.lock)
+  createThread(workers[i], slave, addr(workersData[i]))
+
+proc setup() =
+  currentPoolSize = min(countProcessors(), MaxThreadPoolSize)
+  readyWorker = addr(workersData[0])
+  for i in 0.. <currentPoolSize: activateThread(i)
+
+proc preferSpawn*(): bool =
+  ## Use this proc to determine quickly if a 'spawn' or a direct call is
+  ## preferable. If it returns 'true' a 'spawn' may make sense. In general
+  ## it is not necessary to call this directly; use 'spawnX' instead.
+  result = gSomeReady.counter > 0
+
+proc spawn*(call: expr): expr {.magic: "Spawn".}
+  ## always spawns a new task, so that the 'call' is never executed on
+  ## the calling thread. 'call' has to be proc call 'p(...)' where 'p'
+  ## is gcsafe and has a return type that is either 'void' or compatible
+  ## with ``FlowVar[T]``.
+
+template spawnX*(call: expr): expr =
+  ## spawns a new task if a CPU core is ready, otherwise executes the
+  ## call in the calling thread. Usually it is advised to
+  ## use 'spawn' in order to not block the producer for an unknown
+  ## amount of time. 'call' has to be proc call 'p(...)' where 'p'
+  ## is gcsafe and has a return type that is either 'void' or compatible
+  ## with ``FlowVar[T]``.
+  (if preferSpawn(): spawn call else: call)
+
+proc parallel*(body: stmt) {.magic: "Parallel".}
+  ## a parallel section can be used to execute a block in parallel. ``body``
+  ## has to be in a DSL that is a particular subset of the language. Please
+  ## refer to the manual for further information.
+
+var
+  state: ThreadPoolState
+  stateLock: TLock
+
+initLock stateLock
+
+proc selectWorker(w: ptr Worker; fn: WorkerProc; data: pointer): bool =
+  if cas(addr w.ready, true, false):
+    w.data = data
+    w.f = fn
+    signal(w.taskArrived)
+    await(w.taskStarted)
+    result = true
+
+proc nimSpawn(fn: WorkerProc; data: pointer) {.compilerProc.} =
+  # implementation of 'spawn' that is used by the code generator.
+  while true:
+    if selectWorker(readyWorker, fn, data): return
+    for i in 0.. <currentPoolSize:
+      if selectWorker(addr(workersData[i]), fn, data): return
+    # determine what to do, but keep in mind this is expensive too:
+    # state.calls < maxPoolSize: warmup phase
+    # (state.calls and 127) == 0: periodic check
+    if state.calls < maxPoolSize or (state.calls and 127) == 0:
+      # ensure the call to 'advice' is atomic:
+      if tryAcquire(stateLock):
+        case advice(state)
+        of doNothing: discard
+        of doCreateThread:
+          if currentPoolSize < maxPoolSize:
+            if not workersData[currentPoolSize].initialized:
+              activateThread(currentPoolSize)
+            let w = addr(workersData[currentPoolSize])
+            atomicInc currentPoolSize
+            if selectWorker(w, fn, data):
+              release(stateLock)
+              return
+            # else we didn't succeed but some other thread, so do nothing.
+        of doShutdownThread:
+          if currentPoolSize > minPoolSize:
+            let w = addr(workersData[currentPoolSize-1])
+            w.shutdown = true
+          # we don't free anything here. Too dangerous.
+        release(stateLock)
+      # else the acquire failed, but this means some
+      # other thread succeeded, so we don't need to do anything here.
+    await(gSomeReady)
+
+proc sync*() =
+  ## a simple barrier to wait for all spawn'ed tasks. If you need more elaborate
+  ## waiting, you have to use an explicit barrier.
+  while true:
+    var allReady = true
+    for i in 0 .. <currentPoolSize:
+      if not allReady: break
+      allReady = allReady and workersData[i].ready
+    if allReady: break
+    await(gSomeReady)
+
+setup()
diff --git a/lib/pure/fsmonitor.nim b/lib/pure/fsmonitor.nim
index d6584c1a0..b35466771 100644
--- a/lib/pure/fsmonitor.nim
+++ b/lib/pure/fsmonitor.nim
@@ -119,8 +119,8 @@ proc getEvent(m: PFSMonitor, fd: cint): seq[TMonitorEvent] =
     var mev: TMonitorEvent
     mev.wd = event.wd
     if event.len.int != 0:
-      mev.name = newString(event.len.int)
-      copyMem(addr(mev.name[0]), addr event.name, event.len.int-1)
+      let cstr = event.name.addr.cstring
+      mev.name = $cstr
     else:
       mev.name = ""
     
@@ -211,4 +211,4 @@ when isMainModule:
       
   while true:
     if not disp.poll(): break
-  
\ No newline at end of file
+  
diff --git a/lib/pure/future.nim b/lib/pure/future.nim
index e0e4c4176..b7df05207 100644
--- a/lib/pure/future.nim
+++ b/lib/pure/future.nim
@@ -18,7 +18,6 @@ proc createProcType(p, b: PNimrodNode): PNimrodNode {.compileTime.} =
   result = newNimNode(nnkProcTy)
   var formalParams = newNimNode(nnkFormalParams)
 
-  expectKind(b, nnkIdent)
   formalParams.add b
 
   case p.kind
diff --git a/lib/pure/hashes.nim b/lib/pure/hashes.nim
index 5784a96c1..740355e55 100644
--- a/lib/pure/hashes.nim
+++ b/lib/pure/hashes.nim
@@ -8,7 +8,34 @@
 #
 
 ## This module implements efficient computations of hash values for diverse
-## Nimrod types.
+## Nimrod types. All the procs are based on these two building blocks: the `!&
+## proc <#!&>`_ used to start or mix a hash value, and the `!$ proc <#!$>`_
+## used to *finish* the hash value.  If you want to implement hash procs for
+## your custom types you will end up writing the following kind of skeleton of
+## code:
+##
+## .. code-block:: nimrod
+##  proc hash(x: Something): THash =
+##    ## Computes a THash from `x`.
+##    var h: THash = 0
+##    # Iterate over parts of `x`.
+##    for xAtom in x:
+##      # Mix the atom with the partial hash.
+##      h = h !& xAtom
+##    # Finish the hash.
+##    result = !$h
+##
+## If your custom types contain fields for which there already is a hash proc,
+## like for example objects made up of ``strings``, you can simply hash
+## together the hash value of the individual fields:
+##
+## .. code-block:: nimrod
+##  proc hash(x: Something): THash =
+##    ## Computes a THash from `x`.
+##    var h: THash = 0
+##    h = h &! hash(x.foo)
+##    h = h &! hash(x.bar)
+##    result = !$h
 
 import 
   strutils
diff --git a/lib/pure/httpclient.nim b/lib/pure/httpclient.nim
index be06a7b8e..9bacc80d6 100644
--- a/lib/pure/httpclient.nim
+++ b/lib/pure/httpclient.nim
@@ -654,7 +654,7 @@ when isMainModule:
       resp = await client.request("http://nimrod-lang.org/download.html")
       echo("Got response: ", resp.status)
 
-    main()
+    asyncCheck main()
     runForever()
 
   else:
diff --git a/lib/pure/httpserver.nim b/lib/pure/httpserver.nim
index 8de708c5d..885742b64 100644
--- a/lib/pure/httpserver.nim
+++ b/lib/pure/httpserver.nim
@@ -192,7 +192,7 @@ when false:
     if path[path.len-1] == '/' or existsDir(path):
       path = path / "index.html"
 
-    if not ExistsFile(path):
+    if not existsFile(path):
       discardHeaders(client)
       notFound(client)
     else:
diff --git a/lib/pure/json.nim b/lib/pure/json.nim
index 4250847e5..508e564c5 100644
--- a/lib/pure/json.nim
+++ b/lib/pure/json.nim
@@ -619,6 +619,44 @@ proc `%`*(elements: openArray[PJsonNode]): PJsonNode =
   newSeq(result.elems, elements.len)
   for i, p in pairs(elements): result.elems[i] = p
 
+proc `==`* (a,b: PJsonNode): bool =
+  ## Check two nodes for equality
+  if a.kind != b.kind: false
+  else:
+    case a.kind
+    of JString:
+      a.str == b.str
+    of JInt:
+      a.num == b.num
+    of JFloat:
+      a.fnum == b.fnum
+    of JBool:
+      a.bval == b.bval
+    of JNull:
+      true
+    of JArray:
+      a.elems == b.elems
+    of JObject:
+      a.fields == b.fields
+
+proc hash* (n:PJsonNode): THash =
+  ## Compute the hash for a JSON node
+  case n.kind
+  of JArray:
+    result = hash(n.elems)
+  of JObject:
+    result = hash(n.fields)
+  of JInt:
+    result = hash(n.num)
+  of JFloat:
+    result = hash(n.fnum)
+  of JBool:
+    result = hash(n.bval.int)
+  of JString:
+    result = hash(n.str)
+  of JNull:
+    result = hash(0)
+
 proc len*(n: PJsonNode): int = 
   ## If `n` is a `JArray`, it returns the number of elements.
   ## If `n` is a `JObject`, it returns the number of pairs.
@@ -629,7 +667,9 @@ proc len*(n: PJsonNode): int =
   else: discard
 
 proc `[]`*(node: PJsonNode, name: string): PJsonNode =
-  ## Gets a field from a `JObject`. Returns nil if the key is not found.
+  ## Gets a field from a `JObject`, which must not be nil.
+  ## If the value at `name` does not exist, returns nil
+  assert(not isNil(node))
   assert(node.kind == JObject)
   for key, item in items(node.fields):
     if key == name:
@@ -637,7 +677,9 @@ proc `[]`*(node: PJsonNode, name: string): PJsonNode =
   return nil
   
 proc `[]`*(node: PJsonNode, index: int): PJsonNode =
-  ## Gets the node at `index` in an Array.
+  ## Gets the node at `index` in an Array. Result is undefined if `index`
+  ## is out of bounds
+  assert(not isNil(node))
   assert(node.kind == JArray)
   return node.elems[index]
 
@@ -671,6 +713,23 @@ proc `[]=`*(obj: PJsonNode, key: string, val: PJsonNode) =
       return
   obj.fields.add((key, val))
 
+proc `{}`*(node: PJsonNode, key: string): PJsonNode =
+  ## Transverses the node and gets the given value. If any of the
+  ## names does not exist, returns nil
+  result = node
+  if isNil(node): return nil
+  result = result[key]
+
+proc `{}=`*(node: PJsonNode, names: varargs[string], value: PJsonNode) =
+  ## Transverses the node and tries to set the value at the given location
+  ## to `value` If any of the names are missing, they are added
+  var node = node
+  for i in 0..(names.len-2):
+    if isNil(node[names[i]]):
+      node[names[i]] = newJObject()
+    node = node[names[i]]
+  node[names[names.len-1]] = value
+
 proc delete*(obj: PJsonNode, key: string) =
   ## Deletes ``obj[key]`` preserving the order of the other (key, value)-pairs.
   assert(obj.kind == JObject)
@@ -996,6 +1055,28 @@ when isMainModule:
     raise newException(EInvalidValue, "That line was expected to fail")
   except EInvalidIndex: echo()
 
+  let testJson = parseJson"""{ "a": [1, 2, 3, 4], "b": "asd" }"""
+  # nil passthrough
+  assert(testJson{"doesnt_exist"}{"anything"}.isNil)
+  testJson{["c", "d"]} = %true
+  assert(testJson["c"]["d"].bval)
+
+  # Bounds checking
+  try:
+    let a = testJson["a"][9]
+    assert(false, "EInvalidIndex not thrown")
+  except EInvalidIndex:
+    discard
+  try:
+    let a = testJson["a"][-1]
+    assert(false, "EInvalidIndex not thrown")
+  except EInvalidIndex:
+    discard
+  try:
+    assert(testJson["a"][0].num == 1, "Index doesn't correspond to its value")
+  except:
+    assert(false, "EInvalidIndex thrown for valid index")
+
   discard """
   while true:
     var json = stdin.readLine()
diff --git a/lib/pure/math.nim b/lib/pure/math.nim
index e4aecd272..2f7a696b9 100644
--- a/lib/pure/math.nim
+++ b/lib/pure/math.nim
@@ -10,7 +10,8 @@
 ##   Constructive mathematics is naturally typed. -- Simon Thompson
 ## 
 ## Basic math routines for Nimrod.
-## This module is available for the JavaScript target.
+## This module is available for the `JavaScript target
+## <backends.html#the-javascript-target>`_.
 
 include "system/inclrtl"
 
@@ -135,12 +136,12 @@ proc random*(max: int): int {.gcsafe.}
   ## which initializes the random number generator with a "random"
   ## number, i.e. a tickcount.
 
-when not defined(windows):
-  proc random*(max: float): float {.gcsafe.}
-    ## returns a random number in the range 0..<max. The sequence of
-    ## random number is always the same, unless `randomize` is called
-    ## which initializes the random number generator with a "random"
-    ## number, i.e. a tickcount. This is currently not supported for windows.
+proc random*(max: float): float {.gcsafe.}
+  ## returns a random number in the range 0..<max. The sequence of
+  ## random number is always the same, unless `randomize` is called
+  ## which initializes the random number generator with a "random"
+  ## number, i.e. a tickcount. This has a 16-bit resolution on windows
+  ## and a 48-bit resolution on other platforms.
 
 proc randomize*() {.gcsafe.}
   ## initializes the random number generator with a "random"
@@ -205,7 +206,14 @@ when not defined(JS):
     proc drand48(): float {.importc: "drand48", header: "<stdlib.h>".}
     proc random(max: float): float =
       result = drand48() * max
-    
+  when defined(windows):
+    proc random(max: float): float =
+      # we are hardcodeing this because
+      # importcing macros is extremely problematic
+      # and because the value is publicly documented
+      # on MSDN and very unlikely to change
+      const rand_max = 32767
+      result = (float(rand()) / float(rand_max)) * max
   proc randomize() =
     randomize(cast[int](epochTime()))
 
diff --git a/lib/pure/memfiles.nim b/lib/pure/memfiles.nim
index 807f3da43..31fefc6c8 100644
--- a/lib/pure/memfiles.nim
+++ b/lib/pure/memfiles.nim
@@ -74,9 +74,22 @@ proc unmapMem*(f: var TMemFile, p: pointer, size: int) =
 proc open*(filename: string, mode: TFileMode = fmRead,
            mappedSize = -1, offset = 0, newFileSize = -1): TMemFile =
   ## opens a memory mapped file. If this fails, ``EOS`` is raised.
-  ## `newFileSize` can only be set if the file is not opened with ``fmRead``
-  ## access. `mappedSize` and `offset` can be used to map only a slice of
-  ## the file.
+  ## `newFileSize` can only be set if the file does not exist and is opened
+  ## with write access (e.g., with fmReadWrite). `mappedSize` and `offset`
+  ## can be used to map only a slice of the file. Example:
+  ##
+  ## .. code-block:: nimrod
+  ##   var
+  ##     mm, mm_full, mm_half: TMemFile
+  ##
+  ##   mm = memfiles.open("/tmp/test.mmap", mode = fmWrite, newFileSize = 1024)    # Create a new file
+  ##   mm.close()
+  ##
+  ##   # Read the whole file, would fail if newFileSize was set
+  ##   mm_full = memfiles.open("/tmp/test.mmap", mode = fmReadWrite, mappedSize = -1)
+  ##
+  ##   # Read the first 512 bytes
+  ##   mm_half = memfiles.open("/tmp/test.mmap", mode = fmReadWrite, mappedSize = 512)
 
   # The file can be resized only when write mode is used:
   assert newFileSize == -1 or mode != fmRead
@@ -165,8 +178,11 @@ proc open*(filename: string, mode: TFileMode = fmRead,
 
     if newFileSize != -1:
       flags = flags or O_CREAT or O_TRUNC
+      var permissions_mode = S_IRUSR or S_IWUSR
+      result.handle = open(filename, flags, permissions_mode)
+    else:
+      result.handle = open(filename, flags)
 
-    result.handle = open(filename, flags)
     if result.handle == -1:
       # XXX: errno is supposed to be set here
       # Is there an exception that wraps it?
diff --git a/lib/pure/net.nim b/lib/pure/net.nim
index 74739630b..ddc2bbe2d 100644
--- a/lib/pure/net.nim
+++ b/lib/pure/net.nim
@@ -11,7 +11,7 @@
 
 {.deadCodeElim: on.}
 import rawsockets, os, strutils, unsigned, parseutils, times
-export TPort
+export TPort, `$`
 
 const useWinVersion = defined(Windows) or defined(nimdoc)
 
@@ -350,6 +350,30 @@ type
 
   ETimeout* = object of ESynch
 
+  TSocketFlags* {.pure.} = enum
+    Peek,
+    SafeDisconn ## Ensures disconnection exceptions (ECONNRESET, EPIPE etc) are not thrown.
+
+proc isDisconnectionError*(flags: set[TSocketFlags],
+    lastError: TOSErrorCode): bool =
+  ## Determines whether ``lastError`` is a disconnection error. Only does this
+  ## if flags contains ``SafeDisconn``.
+  when useWinVersion:
+    TSocketFlags.SafeDisconn in flags and
+      lastError.int32 in {WSAECONNRESET, WSAECONNABORTED, WSAENETRESET,
+                          WSAEDISCON}
+  else:
+    TSocketFlags.SafeDisconn in flags and
+      lastError.int32 in {ECONNRESET, EPIPE, ENETRESET} 
+
+proc toOSFlags*(socketFlags: set[TSocketFlags]): cint =
+  ## Converts the flags into the underlying OS representation.
+  for f in socketFlags:
+    case f
+    of TSocketFlags.Peek:
+      result = result or MSG_PEEK
+    of TSocketFlags.SafeDisconn: continue
+
 proc createSocket(fd: TSocketHandle, isBuff: bool): PSocket =
   assert fd != osInvalidSocket
   new(result)
@@ -470,7 +494,8 @@ when defined(ssl):
     if SSLSetFd(socket.sslHandle, socket.fd) != 1:
       SSLError()
 
-proc socketError*(socket: PSocket, err: int = -1, async = false) =
+proc socketError*(socket: PSocket, err: int = -1, async = false,
+                  lastError = (-1).TOSErrorCode) =
   ## Raises an EOS error based on the error code returned by ``SSLGetError``
   ## (for SSL sockets) and ``osLastError`` otherwise.
   ##
@@ -500,17 +525,17 @@ proc socketError*(socket: PSocket, err: int = -1, async = false) =
         else: SSLError("Unknown Error")
   
   if err == -1 and not (when defined(ssl): socket.isSSL else: false):
-    let lastError = osLastError()
+    let lastE = if lastError.int == -1: osLastError() else: lastError
     if async:
       when useWinVersion:
-        if lastError.int32 == WSAEWOULDBLOCK:
+        if lastE.int32 == WSAEWOULDBLOCK:
           return
-        else: osError(lastError)
+        else: osError(lastE)
       else:
-        if lastError.int32 == EAGAIN or lastError.int32 == EWOULDBLOCK:
+        if lastE.int32 == EAGAIN or lastE.int32 == EWOULDBLOCK:
           return
-        else: osError(lastError)
-    else: osError(lastError)
+        else: osError(lastE)
+    else: osError(lastE)
 
 proc listen*(socket: PSocket, backlog = SOMAXCONN) {.tags: [FReadIO].} =
   ## Marks ``socket`` as accepting connections. 
@@ -805,6 +830,7 @@ proc recv*(socket: PSocket, data: pointer, size: int): int {.tags: [FReadIO].} =
     
       let chunk = min(socket.bufLen-socket.currPos, size-read)
       var d = cast[cstring](data)
+      assert size-read >= chunk
       copyMem(addr(d[read]), addr(socket.buffer[socket.currPos]), chunk)
       read.inc(chunk)
       socket.currPos.inc(chunk)
@@ -871,6 +897,7 @@ proc recv*(socket: PSocket, data: pointer, size: int, timeout: int): int {.
   while read < size:
     let avail = waitFor(socket, waited, timeout, size-read, "recv")
     var d = cast[cstring](data)
+    assert avail <= size-read
     result = recv(socket, addr(d[read]), avail)
     if result == 0: break
     if result < 0:
@@ -879,7 +906,8 @@ proc recv*(socket: PSocket, data: pointer, size: int, timeout: int): int {.
   
   result = read
 
-proc recv*(socket: PSocket, data: var string, size: int, timeout = -1): int =
+proc recv*(socket: PSocket, data: var string, size: int, timeout = -1,
+           flags = {TSocketFlags.SafeDisconn}): int =
   ## Higher-level version of ``recv``.
   ##
   ## When 0 is returned the socket's connection has been closed.
@@ -891,11 +919,15 @@ proc recv*(socket: PSocket, data: var string, size: int, timeout = -1): int =
   ## within the time specified an ETimeout exception will be raised.
   ##
   ## **Note**: ``data`` must be initialised.
+  ##
+  ## **Warning**: Only the ``SafeDisconn`` flag is currently supported.
   data.setLen(size)
   result = recv(socket, cstring(data), size, timeout)
   if result < 0:
     data.setLen(0)
-    socket.socketError(result)
+    let lastError = osLastError()
+    if flags.isDisconnectionError(lastError): return
+    socket.socketError(result, lastError = lastError)
   data.setLen(result)
 
 proc peekChar(socket: PSocket, c: var char): int {.tags: [FReadIO].} =
@@ -918,7 +950,8 @@ proc peekChar(socket: PSocket, c: var char): int {.tags: [FReadIO].} =
         return
     result = recv(socket.fd, addr(c), 1, MSG_PEEK)
 
-proc readLine*(socket: PSocket, line: var TaintedString, timeout = -1) {.
+proc readLine*(socket: PSocket, line: var TaintedString, timeout = -1,
+               flags = {TSocketFlags.SafeDisconn}) {.
   tags: [FReadIO, FTime].} =
   ## Reads a line of data from ``socket``.
   ##
@@ -932,11 +965,18 @@ proc readLine*(socket: PSocket, line: var TaintedString, timeout = -1) {.
   ##
   ## A timeout can be specified in miliseconds, if data is not received within
   ## the specified time an ETimeout exception will be raised.
+  ##
+  ## **Warning**: Only the ``SafeDisconn`` flag is currently supported.
   
   template addNLIfEmpty(): stmt =
     if line.len == 0:
       line.add("\c\L")
 
+  template raiseSockError(): stmt {.dirty, immediate.} =
+    let lastError = osLastError()
+    if flags.isDisconnectionError(lastError): setLen(line.string, 0); return
+    socket.socketError(n, lastError = lastError)
+
   var waited = 0.0
 
   setLen(line.string, 0)
@@ -944,14 +984,14 @@ proc readLine*(socket: PSocket, line: var TaintedString, timeout = -1) {.
     var c: char
     discard waitFor(socket, waited, timeout, 1, "readLine")
     var n = recv(socket, addr(c), 1)
-    if n < 0: socket.socketError()
-    elif n == 0: return
+    if n < 0: raiseSockError()
+    elif n == 0: setLen(line.string, 0); return
     if c == '\r':
       discard waitFor(socket, waited, timeout, 1, "readLine")
       n = peekChar(socket, c)
       if n > 0 and c == '\L':
         discard recv(socket, addr(c), 1)
-      elif n <= 0: socket.socketError()
+      elif n <= 0: raiseSockError()
       addNLIfEmpty()
       return
     elif c == '\L': 
@@ -1019,11 +1059,14 @@ proc send*(socket: PSocket, data: pointer, size: int): int {.
       const MSG_NOSIGNAL = 0
     result = send(socket.fd, data, size, int32(MSG_NOSIGNAL))
 
-proc send*(socket: PSocket, data: string) {.tags: [FWriteIO].} =
+proc send*(socket: PSocket, data: string,
+           flags = {TSocketFlags.SafeDisconn}) {.tags: [FWriteIO].} =
   ## sends data to a socket.
   let sent = send(socket, cstring(data), data.len)
   if sent < 0:
-    socketError(socket)
+    let lastError = osLastError()
+    if flags.isDisconnectionError(lastError): return
+    socketError(socket, lastError = lastError)
 
   if sent != data.len:
     raise newException(EOS, "Could not send all data.")
diff --git a/lib/pure/nimprof.nim b/lib/pure/nimprof.nim
index 3d0cc2154..ab7cd1944 100644
--- a/lib/pure/nimprof.nim
+++ b/lib/pure/nimprof.nim
@@ -58,8 +58,9 @@ when not defined(memProfiler):
     ## instruction count measure instead then.
     if intervalInUs <= 0: interval = 0
     else: interval = intervalInUs * 1000 - tickCountCorrection
-  
+
 when withThreads:
+  import locks
   var
     profilingLock: TLock
 
@@ -72,7 +73,7 @@ proc hookAux(st: TStackTrace, costs: int) =
   var last = high(st)
   while last > 0 and isNil(st[last]): dec last
   var h = hash(pointer(st[last])) and high(profileData)
-  
+
   # we use probing for maxChainLen entries and replace the encountered entry
   # with the minimal 'total' value:
   if emptySlots == 0:
@@ -133,7 +134,7 @@ else:
       hookAux(st, 1)
     elif getticks() - t0 > interval:
       hookAux(st, 1)
-      t0 = getticks()  
+      t0 = getticks()
 
 proc getTotal(x: ptr TProfileEntry): int =
   result = if isNil(x): 0 else: x.total
@@ -145,7 +146,7 @@ proc `//`(a, b: int): string =
   result = format("$1/$2 = $3%", a, b, formatFloat(a / b * 100.0, ffDefault, 2))
 
 proc writeProfile() {.noconv.} =
-  when defined(system.TStackTrace): 
+  when defined(system.TStackTrace):
     system.profilerHook = nil
   const filename = "profile_results.txt"
   echo "writing " & filename & "..."
@@ -156,7 +157,7 @@ proc writeProfile() {.noconv.} =
     var entries = 0
     for i in 0..high(profileData):
       if profileData[i] != nil: inc entries
-    
+
     var perProc = initCountTable[string]()
     for i in 0..entries-1:
       var dups = initSet[string]()
@@ -166,7 +167,7 @@ proc writeProfile() {.noconv.} =
         let p = $procname
         if not containsOrIncl(dups, p):
           perProc.inc(p, profileData[i].total)
-    
+
     var sum = 0
     # only write the first 100 entries:
     for i in 0..min(100, entries-1):
diff --git a/lib/pure/oids.nim b/lib/pure/oids.nim
index b3e74d2a1..2843e6c65 100644
--- a/lib/pure/oids.nim
+++ b/lib/pure/oids.nim
@@ -62,9 +62,9 @@ var
 
 proc genOid*(): TOid =
   ## generates a new OID.
-  proc rand(): cint {.importc: "rand", nodecl.}
+  proc rand(): cint {.importc: "rand", header: "<stdlib.h>", nodecl.}
   proc gettime(dummy: ptr cint): cint {.importc: "time", header: "<time.h>".}
-  proc srand(seed: cint) {.importc: "srand", nodecl.}
+  proc srand(seed: cint) {.importc: "srand", header: "<stdlib.h>", nodecl.}
 
   var t = gettime(nil)
   
diff --git a/lib/pure/os.nim b/lib/pure/os.nim
index 00a33db75..0b4538abc 100644
--- a/lib/pure/os.nim
+++ b/lib/pure/os.nim
@@ -1,7 +1,7 @@
 #
 #
 #            Nimrod's Runtime Library
-#        (c) Copyright 2012 Andreas Rumpf
+#        (c) Copyright 2014 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
@@ -1612,6 +1612,20 @@ when defined(linux) or defined(solaris) or defined(bsd) or defined(aix):
       len = readlink(procPath, result, len)
     setLen(result, len)
 
+when not (defined(windows) or defined(macosx)):
+  proc getApplHeuristic(): string =
+    when defined(paramStr):
+      result = string(paramStr(0))
+      # POSIX guaranties that this contains the executable
+      # as it has been executed by the calling process
+      if len(result) > 0 and result[0] != DirSep: # not an absolute path?
+        # iterate over any path in the $PATH environment variable
+        for p in split(string(getEnv("PATH")), {PathSep}):
+          var x = joinPath(p, result)
+          if existsFile(x): return x
+    else:
+      result = ""
+
 when defined(macosx):
   type
     cuint32* {.importc: "unsigned int", nodecl.} = int
@@ -1648,10 +1662,13 @@ proc getAppFilename*(): string {.rtl, extern: "nos$1", tags: [FReadIO].} =
       setlen(result, int(len))
   elif defined(linux) or defined(aix):
     result = getApplAux("/proc/self/exe")
+    if result.len == 0: result = getApplHeuristic()
   elif defined(solaris):
     result = getApplAux("/proc/" & $getpid() & "/path/a.out")
+    if result.len == 0: result = getApplHeuristic()
   elif defined(freebsd):
     result = getApplAux("/proc/" & $getpid() & "/file")
+    if result.len == 0: result = getApplHeuristic()
   elif defined(macosx):
     var size: cuint32
     getExecPath1(nil, size)
@@ -1663,15 +1680,7 @@ proc getAppFilename*(): string {.rtl, extern: "nos$1", tags: [FReadIO].} =
   else:
     # little heuristic that may work on other POSIX-like systems:
     result = string(getEnv("_"))
-    if len(result) == 0:
-      result = string(paramStr(0))
-      # POSIX guaranties that this contains the executable
-      # as it has been executed by the calling process
-      if len(result) > 0 and result[0] != DirSep: # not an absolute path?
-        # iterate over any path in the $PATH environment variable
-        for p in split(string(getEnv("PATH")), {PathSep}):
-          var x = joinPath(p, result)
-          if existsFile(x): return x
+    if result.len == 0: result = getApplHeuristic()
 
 proc getApplicationFilename*(): string {.rtl, extern: "nos$1", deprecated.} =
   ## Returns the filename of the application's executable.
@@ -1760,16 +1769,16 @@ else:
     FileId = TIno
 
 type
-  FileInfo = object
+  FileInfo* = object
     ## Contains information associated with a file object.
-    id: tuple[device: DeviceId, file: FileId] # Device and file id.
-    kind: TPathComponent # Kind of file object - directory, symlink, etc.
-    size: BiggestInt # Size of file.
-    permissions: set[TFilePermission] # File permissions
-    linkCount: BiggestInt # Number of hard links the file object has.
-    lastAccessTime: TTime # Time file was last accessed.
-    lastWriteTime: TTime # Time file was last modified/written to.
-    creationTime: TTime # Time file was created. Not supported on all systems!
+    id*: tuple[device: DeviceId, file: FileId] # Device and file id.
+    kind*: TPathComponent # Kind of file object - directory, symlink, etc.
+    size*: BiggestInt # Size of file.
+    permissions*: set[TFilePermission] # File permissions
+    linkCount*: BiggestInt # Number of hard links the file object has.
+    lastAccessTime*: TTime # Time file was last accessed.
+    lastWriteTime*: TTime # Time file was last modified/written to.
+    creationTime*: TTime # Time file was created. Not supported on all systems!
 
 template rawToFormalFileInfo(rawInfo, formalInfo): expr =
   ## Transforms the native file info structure into the one nimrod uses.
diff --git a/lib/pure/osproc.nim b/lib/pure/osproc.nim
index 6e250f9d5..04a0c2403 100644
--- a/lib/pure/osproc.nim
+++ b/lib/pure/osproc.nim
@@ -1,7 +1,7 @@
 #
 #
 #            Nimrod's Runtime Library
-#        (c) Copyright 2013 Andreas Rumpf
+#        (c) Copyright 2014 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
@@ -13,7 +13,7 @@
 include "system/inclrtl"
 
 import
-  strutils, os, strtabs, streams
+  strutils, os, strtabs, streams, cpuinfo
 
 when defined(windows):
   import winlean
@@ -225,42 +225,10 @@ proc errorHandle*(p: PProcess): TFileHandle {.rtl, extern: "nosp$1",
   ## it is closed when closing the PProcess ``p``.
   result = p.errHandle
 
-when defined(macosx) or defined(bsd):
-  const
-    CTL_HW = 6
-    HW_AVAILCPU = 25
-    HW_NCPU = 3
-  proc sysctl(x: ptr array[0..3, cint], y: cint, z: pointer,
-              a: var csize, b: pointer, c: int): cint {.
-             importc: "sysctl", header: "<sys/sysctl.h>".}
-
 proc countProcessors*(): int {.rtl, extern: "nosp$1".} =
   ## returns the numer of the processors/cores the machine has.
   ## Returns 0 if it cannot be detected.
-  when defined(windows):
-    var x = getEnv("NUMBER_OF_PROCESSORS")
-    if x.len > 0: result = parseInt(x.string)
-  elif defined(macosx) or defined(bsd):
-    var
-      mib: array[0..3, cint]
-      numCPU: int
-      len: csize
-    mib[0] = CTL_HW
-    mib[1] = HW_AVAILCPU
-    len = sizeof(numCPU)
-    discard sysctl(addr(mib), 2, addr(numCPU), len, nil, 0)
-    if numCPU < 1:
-      mib[1] = HW_NCPU
-      discard sysctl(addr(mib), 2, addr(numCPU), len, nil, 0)
-    result = numCPU
-  elif defined(hpux):
-    result = mpctl(MPC_GETNUMSPUS, nil, nil)
-  elif defined(irix):
-    var SC_NPROC_ONLN {.importc: "_SC_NPROC_ONLN", header: "<unistd.h>".}: cint
-    result = sysconf(SC_NPROC_ONLN)
-  else:
-    result = sysconf(SC_NPROCESSORS_ONLN)
-  if result <= 0: result = 1
+  result = cpuinfo.countProcessors()
 
 proc execProcesses*(cmds: openArray[string],
                     options = {poStdErrToStdOut, poParentStreams},
@@ -800,8 +768,8 @@ elif not defined(useNimRtl):
 
   proc startProcessAfterFork(data: ptr TStartProcessData) =
     # Warning: no GC here!
-    # Or anythink that touches global structures - all called nimrod procs
-    # must be marked with noStackFrame. Inspect C code after making changes.
+    # Or anything that touches global structures - all called nimrod procs
+    # must be marked with stackTrace:off. Inspect C code after making changes.
     if not data.optionPoParentStreams:
       discard close(data.pStdin[writeIdx])
       if dup2(data.pStdin[readIdx], readIdx) < 0:
@@ -903,7 +871,7 @@ elif not defined(useNimRtl):
       createStream(p.errStream, p.errHandle, fmRead)
     return p.errStream
 
-  proc csystem(cmd: cstring): cint {.nodecl, importc: "system".}
+  proc csystem(cmd: cstring): cint {.nodecl, importc: "system", header: "<stdlib.h>".}
 
   proc execCmd(command: string): int =
     when defined(linux):
diff --git a/lib/pure/rawsockets.nim b/lib/pure/rawsockets.nim
index 07b647b68..d96741846 100644
--- a/lib/pure/rawsockets.nim
+++ b/lib/pure/rawsockets.nim
@@ -21,11 +21,12 @@ const useWinVersion = defined(Windows) or defined(nimdoc)
 
 when useWinVersion:
   import winlean
-  export WSAEWOULDBLOCK
+  export WSAEWOULDBLOCK, WSAECONNRESET, WSAECONNABORTED, WSAENETRESET,
+         WSAEDISCON
 else:
   import posix
   export fcntl, F_GETFL, O_NONBLOCK, F_SETFL, EAGAIN, EWOULDBLOCK, MSG_NOSIGNAL,
-    EINTR, EINPROGRESS
+    EINTR, EINPROGRESS, ECONNRESET, EPIPE, ENETRESET
 
 export TSocketHandle, TSockaddr_in, TAddrinfo, INADDR_ANY, TSockAddr, TSockLen,
   inet_ntoa, recv, `==`, connect, send, accept, recvfrom, sendto
@@ -39,7 +40,6 @@ export
   MSG_PEEK
 
 type
-  
   TPort* = distinct uint16  ## port type
   
   TDomain* = enum   ## domain, which specifies the protocol family of the
diff --git a/lib/pure/selectors.nim b/lib/pure/selectors.nim
index f630ba235..bd53c2dbf 100644
--- a/lib/pure/selectors.nim
+++ b/lib/pure/selectors.nim
@@ -11,9 +11,12 @@
 
 import tables, os, unsigned, hashes
 
-when defined(linux): import posix, epoll
-elif defined(windows): import winlean
-else: import posix
+when defined(linux): 
+  import posix, epoll
+elif defined(windows): 
+  import winlean
+else: 
+  import posix
 
 proc hash*(x: TSocketHandle): THash {.borrow.}
 proc `$`*(x: TSocketHandle): string {.borrow.}
@@ -29,7 +32,36 @@ type
 
   TReadyInfo* = tuple[key: PSelectorKey, events: set[TEvent]]
 
-when defined(linux) or defined(nimdoc):
+when defined(nimdoc):
+  type
+    PSelector* = ref object
+      ## An object which holds file descripters to be checked for read/write
+      ## status.
+      fds: TTable[TSocketHandle, PSelectorKey]
+
+  proc register*(s: PSelector, fd: TSocketHandle, events: set[TEvent],
+                 data: PObject): PSelectorKey {.discardable.} =
+    ## Registers file descriptor ``fd`` to selector ``s`` with a set of TEvent
+    ## ``events``.
+
+  proc update*(s: PSelector, fd: TSocketHandle,
+               events: set[TEvent]): PSelectorKey {.discardable.} =
+    ## Updates the events which ``fd`` wants notifications for.
+
+  proc select*(s: PSelector, timeout: int): seq[TReadyInfo] =
+    ## The ``events`` field of the returned ``key`` contains the original events
+    ## for which the ``fd`` was bound. This is contrary to the ``events`` field
+    ## of the ``TReadyInfo`` tuple which determines which events are ready
+    ## on the ``fd``.
+
+  proc contains*(s: PSelector, fd: TSocketHandle): bool =
+    ## Determines whether selector contains a file descriptor.
+
+  proc `[]`*(s: PSelector, fd: TSocketHandle): PSelectorKey =
+    ## Retrieves the selector key for ``fd``.
+
+
+elif defined(linux):
   type
     PSelector* = ref object
       epollFD: cint
@@ -49,9 +81,10 @@ when defined(linux) or defined(nimdoc):
     ## Registers file descriptor ``fd`` to selector ``s`` with a set of TEvent
     ## ``events``.
     var event = createEventStruct(events, fd)
-    if epoll_ctl(s.epollFD, EPOLL_CTL_ADD, fd, addr(event)) != 0:
-      OSError(OSLastError())
-  
+    if events != {}:
+      if epoll_ctl(s.epollFD, EPOLL_CTL_ADD, fd, addr(event)) != 0:
+        OSError(OSLastError())
+
     var key = PSelectorKey(fd: fd, events: events, data: data)
   
     s.fds[fd] = key
@@ -61,11 +94,27 @@ when defined(linux) or defined(nimdoc):
       events: set[TEvent]): PSelectorKey {.discardable.} =
     ## Updates the events which ``fd`` wants notifications for.
     if s.fds[fd].events != events:
-      var event = createEventStruct(events, fd)
+      if events == {}:
+        # This fd is idle -- it should not be registered to epoll.
+        # But it should remain a part of this selector instance.
+        # This is to prevent epoll_wait from returning immediately
+        # because its got fds which are waiting for no events and
+        # are therefore constantly ready. (leading to 100% CPU usage).
+        if epoll_ctl(s.epollFD, EPOLL_CTL_DEL, fd, nil) != 0:
+          OSError(OSLastError())
+        s.fds[fd].events = events
+      else:
+        var event = createEventStruct(events, fd)
+        if s.fds[fd].events == {}:
+          # This fd is idle. It's not a member of this epoll instance and must
+          # be re-registered.
+          if epoll_ctl(s.epollFD, EPOLL_CTL_ADD, fd, addr(event)) != 0:
+            OSError(OSLastError())
+        else:
+          if epoll_ctl(s.epollFD, EPOLL_CTL_MOD, fd, addr(event)) != 0:
+            OSError(OSLastError())
+        s.fds[fd].events = events
       
-      s.fds[fd].events = events
-      if epoll_ctl(s.epollFD, EPOLL_CTL_MOD, fd, addr(event)) != 0:
-        OSError(OSLastError())
       result = s.fds[fd]
   
   proc unregister*(s: PSelector, fd: TSocketHandle): PSelectorKey {.discardable.} =
@@ -114,7 +163,7 @@ when defined(linux) or defined(nimdoc):
   proc newSelector*(): PSelector =
     new result
     result.epollFD = epoll_create(64)
-    result.events = cast[array[64, epoll_event]](alloc0(sizeof(epoll_event)*64))
+    #result.events = cast[array[64, epoll_event]](alloc0(sizeof(epoll_event)*64))
     result.fds = initTable[TSocketHandle, PSelectorKey]()
     if result.epollFD < 0:
       OSError(OSLastError())
@@ -123,7 +172,10 @@ when defined(linux) or defined(nimdoc):
     ## Determines whether selector contains a file descriptor.
     if s.fds.hasKey(fd):
       # Ensure the underlying epoll instance still contains this fd.
-      result = epollHasFd(s, fd)
+      if s.fds[fd].events != {}:
+        result = epollHasFd(s, fd)
+      else:
+        result = true
     else:
       return false
 
@@ -131,7 +183,7 @@ when defined(linux) or defined(nimdoc):
     ## Retrieves the selector key for ``fd``.
     return s.fds[fd]
 
-else:
+elif not defined(nimdoc):
   # TODO: kqueue for bsd/mac os x.
   type
     PSelector* = ref object
@@ -230,7 +282,7 @@ proc contains*(s: PSelector, key: PSelectorKey): bool =
   ## the new one may have the same value.
   return key.fd in s and s.fds[key.fd] == key
 
-when isMainModule:
+when isMainModule and not defined(nimdoc):
   # Select()
   import sockets
   type
diff --git a/lib/pure/sockets.nim b/lib/pure/sockets.nim
index 8d96cbaaf..7b8b3d557 100644
--- a/lib/pure/sockets.nim
+++ b/lib/pure/sockets.nim
@@ -295,7 +295,7 @@ when defined(ssl):
     of protSSLv23:
       newCTX = SSL_CTX_new(SSLv23_method()) # SSlv2,3 and TLS1 support.
     of protSSLv2:
-      when not defined(linux):
+      when not defined(linux) and not defined(OpenBSD):
         newCTX = SSL_CTX_new(SSLv2_method())
       else:
         SSLError()
diff --git a/lib/pure/strutils.nim b/lib/pure/strutils.nim
index bd6814dcc..e642f6a99 100644
--- a/lib/pure/strutils.nim
+++ b/lib/pure/strutils.nim
@@ -10,6 +10,8 @@
 ## This module contains various string utility routines.
 ## See the module `re <re.html>`_ for regular expression support.
 ## See the module `pegs <pegs.html>`_ for PEG support.
+## This module is available for the `JavaScript target
+## <backends.html#the-javascript-target>`_.
 
 import parseutils
 
diff --git a/lib/pure/times.nim b/lib/pure/times.nim
index fdff06b2a..498511899 100644
--- a/lib/pure/times.nim
+++ b/lib/pure/times.nim
@@ -9,7 +9,8 @@
 
 
 ## This module contains routines and types for dealing with time.
-## This module is available for the JavaScript target.
+## This module is available for the `JavaScript target
+## <backends.html#the-javascript-target>`_.
 
 {.push debugger:off.} # the user does not want to trace a part
                       # of the standard library!
diff --git a/lib/system.nim b/lib/system.nim
index 4a5d46a7f..3bb632536 100644
--- a/lib/system.nim
+++ b/lib/system.nim
@@ -42,15 +42,18 @@ type
   cstring* {.magic: Cstring.} ## built-in cstring (*compatible string*) type
   pointer* {.magic: Pointer.} ## built-in pointer type, use the ``addr``
                               ## operator to get a pointer to a variable
-
 const
   on* = true    ## alias for ``true``
   off* = false  ## alias for ``false``
 
+{.push warning[GcMem]: off.}
 {.push hints: off.}
 
 type
   Ordinal* {.magic: Ordinal.}[T]
+  `ptr`* {.magic: Pointer.}[T] ## built-in generic untraced pointer type
+  `ref`* {.magic: Pointer.}[T] ## built-in generic traced pointer type
+
   `nil` {.magic: "Nil".}
   expr* {.magic: Expr.} ## meta type to denote an expression (for templates)
   stmt* {.magic: Stmt.} ## meta type to denote a statement (for templates)
@@ -88,6 +91,15 @@ proc defined*(x: expr): bool {.magic: "Defined", noSideEffect.}
   ##   when not defined(strutils.toUpper):
   ##     # provide our own toUpper proc here, because strutils is
   ##     # missing it.
+  ##
+  ## You can also check external symbols introduced through the compiler's
+  ## `-d:x switch <nimrodc.html#compile-time-symbols>`_ to enable build time
+  ## conditionals:
+  ##
+  ## .. code-block:: Nimrod
+  ##   when not defined(release):
+  ##     # Do here programmer friendly expensive sanity checks.
+  ##   # Put here the normal code
 
 when defined(useNimRtl):
   {.deadCodeElim: on.}
@@ -234,6 +246,11 @@ template `>` * (x, y: expr): expr {.immediate.} =
   ## "is greater" operator. This is the same as ``y < x``.
   y < x
 
+const
+  appType* {.magic: "AppType"}: string = ""
+    ## a string that describes the application type. Possible values:
+    ## "console", "gui", "lib".
+
 include "system/inclrtl"
 
 const NoFakeVars* = defined(NimrodVM) ## true if the backend doesn't support \
@@ -415,12 +432,12 @@ proc pred*[T](x: Ordinal[T], y = 1): T {.magic: "Pred", noSideEffect.}
   ## an ordinal type. If such a value does not exist, ``EOutOfRange`` is raised
   ## or a compile time error occurs.
 
-proc inc*[T](x: var Ordinal[T], y = 1) {.magic: "Inc", noSideEffect.}
+proc inc*[T: Ordinal|uint|uint64](x: var T, y = 1) {.magic: "Inc", noSideEffect.}
   ## increments the ordinal ``x`` by ``y``. If such a value does not
   ## exist, ``EOutOfRange`` is raised or a compile time error occurs. This is a
   ## short notation for: ``x = succ(x, y)``.
 
-proc dec*[T](x: var Ordinal[T], y = 1) {.magic: "Dec", noSideEffect.}
+proc dec*[T: Ordinal|uint|uint64](x: var T, y = 1) {.magic: "Dec", noSideEffect.}
   ## decrements the ordinal ``x`` by ``y``. If such a value does not
   ## exist, ``EOutOfRange`` is raised or a compile time error occurs. This is a
   ## short notation for: ``x = pred(x, y)``.
@@ -940,10 +957,6 @@ const
     ## a string that describes the host CPU. Possible values:
     ## "i386", "alpha", "powerpc", "sparc", "amd64", "mips", "arm".
   
-  appType* {.magic: "AppType"}: string = ""
-    ## a string that describes the application type. Possible values:
-    ## "console", "gui", "lib".
-  
   seqShallowFlag = low(int)
   
 proc compileOption*(option: string): bool {.
@@ -1433,6 +1446,20 @@ when not defined(nimrodVM) and hostOS != "standalone":
   proc getTotalMem*(): int {.rtl.}
     ## returns the number of bytes that are owned by the process.
 
+  when hasThreadSupport:
+    proc getOccupiedSharedMem*(): int {.rtl.}
+      ## returns the number of bytes that are owned by the process
+      ## on the shared heap and hold data. This is only available when
+      ## threads are enabled.
+
+    proc getFreeSharedMem*(): int {.rtl.}
+      ## returns the number of bytes that are owned by the
+      ## process on the shared heap, but do not hold any meaningful data.
+      ## This is only available when threads are enabled.
+
+    proc getTotalSharedMem*(): int {.rtl.}
+      ## returns the number of bytes on the shared heap that are owned by the
+      ## process. This is only available when threads are enabled.
 
 iterator countdown*[T](a, b: T, step = 1): T {.inline.} =
   ## Counts from ordinal value `a` down to `b` with the given
@@ -1752,9 +1779,38 @@ iterator fields*[S:tuple|object, T:tuple|object](x: S, y: T): tuple[a,b: expr] {
   ## in the loop body.
 iterator fieldPairs*[T: tuple|object](x: T): TObject {.
   magic: "FieldPairs", noSideEffect.}
-  ## iterates over every field of `x`. Warning: This really transforms
-  ## the 'for' and unrolls the loop. The current implementation also has a bug
-  ## that affects symbol binding in the loop body.
+  ## Iterates over every field of `x` returning their name and value.
+  ##
+  ## When you iterate over objects with different field types you have to use
+  ## the compile time ``when`` instead of a runtime ``if`` to select the code
+  ## you want to run for each type. To perform the comparison use the `is
+  ## operator <manual.html#is-operator>`_. Example:
+  ##
+  ## .. code-block:: Nimrod
+  ##
+  ##   type
+  ##     Custom = object
+  ##       foo: string
+  ##       bar: bool
+  ##
+  ##   proc `$`(x: Custom): string =
+  ##     result = "Custom:"
+  ##     for name, value in x.fieldPairs:
+  ##       when value is bool:
+  ##         result.add("\n\t" & name & " is " & $value)
+  ##       else:
+  ##         if value.isNil:
+  ##           result.add("\n\t" & name & " (nil)")
+  ##         else:
+  ##           result.add("\n\t" & name & " '" & value & "'")
+  ##
+  ## Another way to do the same without ``when`` is to leave the task of
+  ## picking the appropriate code to a secondary proc which you overload for
+  ## each field type and pass the `value` to.
+  ##
+  ## Warning: This really transforms the 'for' and unrolls the loop. The
+  ## current implementation also has a bug that affects symbol binding in the
+  ## loop body.
 iterator fieldPairs*[S: tuple|object, T: tuple|object](x: S, y: T): tuple[
   a, b: expr] {.
   magic: "FieldPairs", noSideEffect.}
@@ -2412,7 +2468,7 @@ when not defined(JS): #and not defined(NimrodVM):
       ##     for line in filename.lines:
       ##       buffer.add(line.replace("a", "0") & '\x0A')
       ##     writeFile(filename, buffer)
-      var f = open(filename)
+      var f = open(filename, bufSize=8000)
       var res = TaintedString(newStringOfCap(80))
       while f.readLine(res): yield res
       close(f)
@@ -2608,6 +2664,8 @@ when hostOS != "standalone":
 proc `[]`*[Idx, T](a: array[Idx, T], x: TSlice[int]): seq[T] =
   ## slice operation for arrays. Negative indexes are **not** supported
   ## because the array might have negative bounds.
+  when low(a) < 0:
+    {.error: "Slicing for arrays with negative indices is unsupported.".}
   var L = x.b - x.a + 1
   newSeq(result, L)
   for i in 0.. <L: result[i] = a[i + x.a]
@@ -2615,11 +2673,13 @@ proc `[]`*[Idx, T](a: array[Idx, T], x: TSlice[int]): seq[T] =
 proc `[]=`*[Idx, T](a: var array[Idx, T], x: TSlice[int], b: openArray[T]) =
   ## slice assignment for arrays. Negative indexes are **not** supported
   ## because the array might have negative bounds.
+  when low(a) < 0:
+    {.error: "Slicing for arrays with negative indices is unsupported.".}
   var L = x.b - x.a + 1
   if L == b.len:
     for i in 0 .. <L: a[i+x.a] = b[i]
   else:
-    sysFatal(EOutOfRange, "differing lengths for slice assignment")
+    sysFatal(EOutOfRange, "different lengths for slice assignment")
 
 proc `[]`*[Idx, T](a: array[Idx, T], x: TSlice[Idx]): seq[T] =
   ## slice operation for arrays. Negative indexes are **not** supported
@@ -2641,7 +2701,7 @@ proc `[]=`*[Idx, T](a: var array[Idx, T], x: TSlice[Idx], b: openArray[T]) =
       a[j] = b[i]
       inc(j)
   else:
-    sysFatal(EOutOfRange, "differing lengths for slice assignment")
+    sysFatal(EOutOfRange, "different lengths for slice assignment")
 
 proc `[]`*[T](s: seq[T], x: TSlice[int]): seq[T] = 
   ## slice operation for sequences. Negative indexes are supported.
@@ -2690,13 +2750,13 @@ proc staticExec*(command: string, input = ""): string {.
   ## inside a pragma like `passC <nimrodc.html#passc-pragma>`_ or `passL
   ## <nimrodc.html#passl-pragma>`_.
 
-proc `+=`*[T: TOrdinal](x: var T, y: T) {.magic: "Inc", noSideEffect.}
+proc `+=`*[T: TOrdinal|uint|uint64](x: var T, y: T) {.magic: "Inc", noSideEffect.}
   ## Increments an ordinal
 
-proc `-=`*[T: TOrdinal](x: var T, y: T) {.magic: "Dec", noSideEffect.}
+proc `-=`*[T: TOrdinal|uint|uint64](x: var T, y: T) {.magic: "Dec", noSideEffect.}
   ## Decrements an ordinal
 
-proc `*=`*[T: TOrdinal](x: var T, y: T) {.inline, noSideEffect.} =
+proc `*=`*[T: TOrdinal|uint|uint64](x: var T, y: T) {.inline, noSideEffect.} =
   ## Binary `*=` operator for ordinals
   x = x * y
 
@@ -2718,9 +2778,6 @@ proc `/=`*[T: float|float32|float64] (x: var T, y: T) {.inline, noSideEffect.} =
 
 proc `&=`* (x: var string, y: string) {.magic: "AppendStrStr", noSideEffect.}
 
-proc rand*(max: int): int {.magic: "Rand", sideEffect.}
-  ## compile-time `random` function. Useful for debugging.
-
 proc astToStr*[T](x: T): string {.magic: "AstToStr", noSideEffect.}
   ## converts the AST of `x` into a string representation. This is very useful
   ## for debugging.
@@ -2771,10 +2828,15 @@ when true:
     THide(raiseAssert)(msg)
 
 template assert*(cond: bool, msg = "") =
-  ## provides a means to implement `programming by contracts`:idx: in Nimrod.
+  ## Raises ``EAssertionFailure`` with `msg` if `cond` is false.
+  ##
+  ## Provides a means to implement `programming by contracts`:idx: in Nimrod.
   ## ``assert`` evaluates expression ``cond`` and if ``cond`` is false, it
-  ## raises an ``EAssertionFailure`` exception. However, the compiler may
-  ## not generate any code at all for ``assert`` if it is advised to do so.
+  ## raises an ``EAssertionFailure`` exception. However, the compiler may not
+  ## generate any code at all for ``assert`` if it is advised to do so through
+  ## the ``-d:release`` or ``--assertions:off`` `command line switches
+  ## <nimrodc.html#command-line-switches>`_.
+  ##
   ## Use ``assert`` for debugging purposes only.
   bind instantiationInfo
   mixin failedAssertImpl
@@ -2928,6 +2990,12 @@ proc locals*(): TObject {.magic: "Locals", noSideEffect.} =
   ##   # -> B is 1
   discard
 
+proc deepCopy*[T](x: T): T {.magic: "DeepCopy", noSideEffect.} = discard
+  ## performs a deep copy of `x`. This is also used by the code generator
+  ## for the implementation of ``spawn``.
+
+{.pop.} #{.push warning[GcMem]: off.}
+
 when not defined(booting):
   type
     semistatic*[T] = static[T] | T
@@ -2936,6 +3004,3 @@ when not defined(booting):
 
   template isStatic*(x): expr = compiles(static(x))
     # checks whether `x` is a value known at compile-time
-
-when hasThreadSupport:
-  when hostOS != "standalone": include "system/sysspawn"
diff --git a/lib/system/alloc.nim b/lib/system/alloc.nim
index eaef6cd95..602e5c7fa 100644
--- a/lib/system/alloc.nim
+++ b/lib/system/alloc.nim
@@ -835,4 +835,20 @@ template instantiateForRegion(allocator: expr) =
     else:
       result = realloc(p, newsize)
 
+  when hasThreadSupport:
+
+    template sharedMemStatsShared(v: int) {.immediate.} =
+      acquireSys(heapLock)
+      result = v
+      releaseSys(heapLock)
+
+    proc getFreeSharedMem(): int =
+      sharedMemStatsShared(sharedHeap.freeMem)
+
+    proc getTotalSharedMem(): int =
+      sharedMemStatsShared(sharedHeap.currMem)
+
+    proc getOccupiedSharedMem(): int =
+      sharedMemStatsShared(sharedHeap.currMem - sharedHeap.freeMem)
+
 {.pop.}
diff --git a/lib/system/ansi_c.nim b/lib/system/ansi_c.nim
index 2d33965e3..5111bc3cf 100644
--- a/lib/system/ansi_c.nim
+++ b/lib/system/ansi_c.nim
@@ -57,6 +57,7 @@ when not defined(SIGINT):
         SIGINT = cint(2)
         SIGSEGV = cint(11)
         SIGTERM = cint(15)
+        SIGPIPE = cint(13)
     else:
       {.error: "SIGABRT not ported to your platform".}
   else:
@@ -66,6 +67,8 @@ when not defined(SIGINT):
       SIGABRT {.importc: "SIGABRT", nodecl.}: cint
       SIGFPE {.importc: "SIGFPE", nodecl.}: cint
       SIGILL {.importc: "SIGILL", nodecl.}: cint
+    when defined(macosx) or defined(linux):
+      var SIGPIPE {.importc: "SIGPIPE", nodecl.}: cint
 
 when defined(macosx):
   when NoFakeVars:
diff --git a/lib/system/assign.nim b/lib/system/assign.nim
index 75c749633..2ae945fb1 100644
--- a/lib/system/assign.nim
+++ b/lib/system/assign.nim
@@ -179,7 +179,8 @@ when not defined(nimmixin):
     # internal proc used for destroying sequences and arrays
     for i in countup(0, r.len - 1): destroy(r[i])
 else:
-  # XXX Why is this exported and no compilerproc?
+  # XXX Why is this exported and no compilerproc? -> compilerprocs cannot be
+  # generic for now
   proc nimDestroyRange*[T](r: T) =
     # internal proc used for destroying sequences and arrays
     mixin destroy
diff --git a/lib/system/atomics.nim b/lib/system/atomics.nim
index b1a96b209..43b3f0438 100644
--- a/lib/system/atomics.nim
+++ b/lib/system/atomics.nim
@@ -1,15 +1,18 @@
 #
 #
 #            Nimrod's Runtime Library
-#        (c) Copyright 2012 Andreas Rumpf
+#        (c) Copyright 2014 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
 #
 
 ## Atomic operations for Nimrod.
+{.push stackTrace:off.}
 
-when (defined(gcc) or defined(llvm_gcc)) and hasThreadSupport:
+const someGcc = defined(gcc) or defined(llvm_gcc) or defined(clang)
+
+when someGcc and hasThreadSupport:
   type 
     AtomMemModel* = enum
       ATOMIC_RELAXED,  ## No barriers or synchronization. 
@@ -152,41 +155,16 @@ when (defined(gcc) or defined(llvm_gcc)) and hasThreadSupport:
     ## A value of 0 indicates typical alignment should be used. The compiler may also 
     ## ignore this parameter.
 
+  template fence*() = atomicThreadFence(ATOMIC_SEQ_CST)
 elif defined(vcc) and hasThreadSupport:
   proc addAndFetch*(p: ptr int, val: int): int {.
     importc: "NimXadd", nodecl.}
+
 else:
   proc addAndFetch*(p: ptr int, val: int): int {.inline.} =
     inc(p[], val)
     result = p[]
 
-# atomic compare and swap (CAS) funcitons to implement lock-free algorithms  
-      
-#if defined(windows) and not defined(gcc) and hasThreadSupport:
-#    proc InterlockedCompareExchangePointer(mem: ptr pointer,
-#      newValue: pointer, comparand: pointer) : pointer {.nodecl, 
-#        importc: "InterlockedCompareExchangePointer", header:"windows.h".}
-
-#    proc compareAndSwap*[T](mem: ptr T, 
-#      expected: T, newValue: T): bool {.inline.}=
-#      ## Returns true if successfully set value at mem to newValue when value
-#      ## at mem == expected
-#      return InterlockedCompareExchangePointer(addr(mem), 
-#        addr(newValue), addr(expected))[] == expected
-    
-#elif not hasThreadSupport:
-#  proc compareAndSwap*[T](mem: ptr T, 
-#                          expected: T, newValue: T): bool {.inline.} =
-#      ## Returns true if successfully set value at mem to newValue when value
-#      ## at mem == expected
-#      var oldval = mem[]
-#      if oldval == expected:
-#        mem[] = newValue
-#        return true
-#      return false
-
-
-# Some convenient functions 
 proc atomicInc*(memLoc: var int, x: int = 1): int =
   when defined(gcc) and hasThreadSupport:
     result = atomic_add_fetch(memLoc.addr, x, ATOMIC_RELAXED)
@@ -203,3 +181,37 @@ proc atomicDec*(memLoc: var int, x: int = 1): int =
   else:
     dec(memLoc, x)
     result = memLoc
+
+when defined(windows) and not someGcc:
+  proc interlockedCompareExchange(p: pointer; exchange, comparand: int32): int32
+    {.importc: "InterlockedCompareExchange", header: "<windows.h>", cdecl.}
+
+  proc cas*[T: bool|int|ptr](p: ptr T; oldValue, newValue: T): bool =
+    interlockedCompareExchange(p, newValue.int32, oldValue.int32) != 0
+  # XXX fix for 64 bit build
+else:
+  # this is valid for GCC and Intel C++
+  proc cas*[T: bool|int|ptr](p: ptr T; oldValue, newValue: T): bool
+    {.importc: "__sync_bool_compare_and_swap", nodecl.}
+  # XXX is this valid for 'int'?
+
+
+when (defined(x86) or defined(amd64)) and (defined(gcc) or defined(llvm_gcc)):
+  proc cpuRelax {.inline.} =
+    {.emit: """asm volatile("pause" ::: "memory");""".}
+elif (defined(x86) or defined(amd64)) and defined(vcc):
+  proc cpuRelax {.importc: "YieldProcessor", header: "<windows.h>".}
+elif defined(intelc):
+  proc cpuRelax {.importc: "_mm_pause", header: "xmmintrin.h".}
+elif false:
+  from os import sleep
+
+  proc cpuRelax {.inline.} = os.sleep(1)
+
+when not defined(fence) and hasThreadSupport:
+  # XXX fixme
+  proc fence*() {.inline.} =
+    var dummy: bool
+    discard cas(addr dummy, false, true)
+
+{.pop.}
diff --git a/lib/system/chcks.nim b/lib/system/chcks.nim
index f29e222e8..387b54ef1 100644
--- a/lib/system/chcks.nim
+++ b/lib/system/chcks.nim
@@ -67,6 +67,28 @@ proc chckObjAsgn(a, b: PNimType) {.compilerproc, inline.} =
   if a != b:
     sysFatal(EInvalidObjectAssignment, "invalid object assignment")
 
+type ObjCheckCache = array[0..1, PNimType]
+
+proc isObjSlowPath(obj, subclass: PNimType;
+                   cache: var ObjCheckCache): bool {.noinline.} =
+  # checks if obj is of type subclass:
+  var x = obj.base
+  while x != subclass:
+    if x == nil:
+      cache[0] = obj
+      return false
+    x = x.base
+  cache[1] = obj
+  return true
+
+proc isObjWithCache(obj, subclass: PNimType;
+                    cache: var ObjCheckCache): bool {.compilerProc, inline.} =
+  if obj == subclass: return true
+  if obj.base == subclass: return true
+  if cache[0] == obj: return false
+  if cache[1] == obj: return true
+  return isObjSlowPath(obj, subclass, cache)
+
 proc isObj(obj, subclass: PNimType): bool {.compilerproc.} =
   # checks if obj is of type subclass:
   var x = obj
diff --git a/lib/system/excpt.nim b/lib/system/excpt.nim
index 2f7c5ed51..63a61183f 100644
--- a/lib/system/excpt.nim
+++ b/lib/system/excpt.nim
@@ -77,7 +77,7 @@ proc popCurrentException {.compilerRtl, inl.} =
 
 # some platforms have native support for stack traces:
 const
-  nativeStackTraceSupported = (defined(macosx) or defined(linux)) and 
+  nativeStackTraceSupported* = (defined(macosx) or defined(linux)) and
                               not nimrodStackTrace
   hasSomeStackTrace = nimrodStackTrace or 
     defined(nativeStackTrace) and nativeStackTraceSupported
@@ -298,7 +298,13 @@ when not defined(noSignalHandler):
       elif s == SIGILL: action("SIGILL: Illegal operation.\n")
       elif s == SIGBUS: 
         action("SIGBUS: Illegal storage access. (Attempt to read from nil?)\n")
-      else: action("unknown signal\n")
+      else:
+        block platformSpecificSignal:
+          when defined(SIGPIPE):
+            if s == SIGPIPE:
+              action("SIGPIPE: Pipe closed.\n")
+              break platformSpecificSignal
+          action("unknown signal\n")
 
     # print stack trace and quit
     when hasSomeStackTrace:
@@ -323,6 +329,8 @@ when not defined(noSignalHandler):
     c_signal(SIGFPE, signalHandler)
     c_signal(SIGILL, signalHandler)
     c_signal(SIGBUS, signalHandler)
+    when defined(SIGPIPE):
+      c_signal(SIGPIPE, signalHandler)
 
   registerSignalHandler() # call it in initialization section
 
diff --git a/lib/system/gc_ms.nim b/lib/system/gc_ms.nim
index 3c99a57e1..05bcdcc82 100644
--- a/lib/system/gc_ms.nim
+++ b/lib/system/gc_ms.nim
@@ -48,12 +48,15 @@ type
                              # non-zero count table
     stackBottom: pointer
     cycleThreshold: int
+    when useCellIds:
+      idGenerator: int
     when withBitvectors:
       allocated, marked: TCellSet
     tempStack: TCellSeq      # temporary stack for recursion elimination
     recGcLock: int           # prevent recursion via finalizers; no thread lock
     region: TMemRegion       # garbage collected region
     stat: TGcStat
+    additionalRoots: TCellSeq # dummy roots for GC_ref/unref
 
 var
   gch {.rtlThreadVar.}: TGcHeap
@@ -131,13 +134,27 @@ proc prepareDealloc(cell: PCell) =
     (cast[TFinalizer](cell.typ.finalizer))(cellToUsr(cell))
     dec(gch.recGcLock)
 
-proc nimGCref(p: pointer) {.compilerProc, inline.} = 
+proc nimGCref(p: pointer) {.compilerProc.} = 
   # we keep it from being collected by pretending it's not even allocated:
-  when withBitvectors: excl(gch.allocated, usrToCell(p))
-  else: usrToCell(p).refcount = rcBlack
-proc nimGCunref(p: pointer) {.compilerProc, inline.} = 
-  when withBitvectors: incl(gch.allocated, usrToCell(p))
-  else: usrToCell(p).refcount = rcWhite
+  when false:
+    when withBitvectors: excl(gch.allocated, usrToCell(p))
+    else: usrToCell(p).refcount = rcBlack
+  add(gch.additionalRoots, usrToCell(p))
+
+proc nimGCunref(p: pointer) {.compilerProc.} =
+  let cell = usrToCell(p)
+  var L = gch.additionalRoots.len-1
+  var i = L
+  let d = gch.additionalRoots.d
+  while i >= 0:
+    if d[i] == cell:
+      d[i] = d[L]
+      dec gch.additionalRoots.len
+      break
+    dec(i)
+  when false:
+    when withBitvectors: incl(gch.allocated, usrToCell(p))
+    else: usrToCell(p).refcount = rcWhite
 
 proc initGC() =
   when not defined(useNimRtl):
@@ -146,6 +163,7 @@ proc initGC() =
     gch.stat.maxThreshold = 0
     gch.stat.maxStackSize = 0
     init(gch.tempStack)
+    init(gch.additionalRoots)
     when withBitvectors:
       Init(gch.allocated)
       init(gch.marked)
@@ -212,8 +230,16 @@ proc rawNewObj(typ: PNimType, size: int, gch: var TGcHeap): pointer =
   res.refcount = 0
   release(gch)
   when withBitvectors: incl(gch.allocated, res)
+  when useCellIds:
+    inc gch.idGenerator
+    res.id = gch.idGenerator
   result = cellToUsr(res)
 
+when useCellIds:
+  proc getCellId*[T](x: ref T): int =
+    let p = usrToCell(cast[pointer](x))
+    result = p.id
+
 {.pop.}
 
 proc newObj(typ: PNimType, size: int): pointer {.compilerRtl.} =
@@ -262,6 +288,9 @@ proc growObj(old: pointer, newsize: int, gch: var TGcHeap): pointer =
   else:
     zeroMem(ol, sizeof(TCell))
   when withBitvectors: incl(gch.allocated, res)
+  when useCellIds:
+    inc gch.idGenerator
+    res.id = gch.idGenerator
   release(gch)
   result = cellToUsr(res)
   when defined(memProfiler): nimProfile(newsize-oldsize)
@@ -284,6 +313,7 @@ proc mark(gch: var TGcHeap, c: PCell) =
       if not containsOrIncl(gch.marked, d):
         forAllChildren(d, waMarkPrecise)
   else:
+    # XXX no 'if c.refCount != rcBlack' here?
     c.refCount = rcBlack
     gcAssert gch.tempStack.len == 0, "stack not empty!"
     forAllChildren(c, waMarkPrecise)
@@ -332,8 +362,19 @@ proc sweep(gch: var TGcHeap) =
         if c.refcount == rcBlack: c.refcount = rcWhite
         else: freeCyclicCell(gch, c)
 
+when false:
+  proc newGcInvariant*() =
+    for x in allObjects(gch.region):
+      if isCell(x):
+        var c = cast[PCell](x)
+        if c.typ == nil:
+          writeStackTrace()
+          quit 1
+
 proc markGlobals(gch: var TGcHeap) =
   for i in 0 .. < globalMarkersLen: globalMarkers[i]()
+  let d = gch.additionalRoots.d
+  for i in 0 .. < gch.additionalRoots.len: mark(gch, d[i])
 
 proc gcMark(gch: var TGcHeap, p: pointer) {.inline.} =
   # the addresses are not as cells on the stack, so turn them to cells:
diff --git a/lib/system/inclrtl.nim b/lib/system/inclrtl.nim
index 12eb90162..5c82db4da 100644
--- a/lib/system/inclrtl.nim
+++ b/lib/system/inclrtl.nim
@@ -1,7 +1,7 @@
 #
 #
 #            Nimrod's Runtime Library
-#        (c) Copyright 2013 Andreas Rumpf
+#        (c) Copyright 2014 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
diff --git a/lib/system/sets.nim b/lib/system/sets.nim
index 043d37533..794c65cb8 100644
--- a/lib/system/sets.nim
+++ b/lib/system/sets.nim
@@ -10,7 +10,7 @@
 # set handling
 
 type
-  TNimSet = array [0..4*2048-1, int8]
+  TNimSet = array [0..4*2048-1, uint8]
 
 proc countBits32(n: int32): int {.compilerproc.} =
   var v = n
@@ -25,4 +25,4 @@ proc countBits64(n: int64): int {.compilerproc.} =
 proc cardSet(s: TNimSet, len: int): int {.compilerproc.} =
   result = 0
   for i in countup(0, len-1):
-    inc(result, countBits32(int32(ze(s[i]))))
+    inc(result, countBits32(int32(s[i])))
diff --git a/lib/system/sysio.nim b/lib/system/sysio.nim
index 02c17b92b..32d4c3e91 100644
--- a/lib/system/sysio.nim
+++ b/lib/system/sysio.nim
@@ -115,10 +115,14 @@ proc readAllBuffer(file: TFile): string =
   # bytes we need to read before the buffer is empty.
   result = ""
   var buffer = newString(BufSize)
-  var bytesRead = BufSize
-  while bytesRead == BufSize:
-    bytesRead = readBuffer(file, addr(buffer[0]), BufSize)
-    result.add(buffer)
+  while true:
+    var bytesRead = readBuffer(file, addr(buffer[0]), BufSize)
+    if bytesRead == BufSize:
+      result.add(buffer)
+    else:
+      buffer.setLen(bytesRead)
+      result.add(buffer)
+      break
   
 proc rawFileSize(file: TFile): int = 
   # this does not raise an error opposed to `getFileSize`
diff --git a/lib/system/sysspawn.nim b/lib/system/sysspawn.nim
index dabf35a3e..95cdba65d 100644
--- a/lib/system/sysspawn.nim
+++ b/lib/system/sysspawn.nim
@@ -14,30 +14,6 @@ when not defined(NimString):
 
 {.push stackTrace:off.}
 
-when (defined(x86) or defined(amd64)) and defined(gcc):
-  proc cpuRelax {.inline.} =
-    {.emit: """asm volatile("pause" ::: "memory");""".}
-elif (defined(x86) or defined(amd64)) and defined(vcc):
-  proc cpuRelax {.importc: "YieldProcessor", header: "<windows.h>".}
-elif defined(intelc):
-  proc cpuRelax {.importc: "_mm_pause", header: "xmmintrin.h".}
-elif false:
-  from os import sleep
-
-  proc cpuRelax {.inline.} = os.sleep(1)
-
-when defined(windows) and not defined(gcc):
-  proc interlockedCompareExchange(p: pointer; exchange, comparand: int32): int32
-    {.importc: "InterlockedCompareExchange", header: "<windows.h>", cdecl.}
-
-  proc cas(p: ptr bool; oldValue, newValue: bool): bool =
-    interlockedCompareExchange(p, newValue.int32, oldValue.int32) != 0
-
-else:
-  # this is valid for GCC and Intel C++
-  proc cas(p: ptr bool; oldValue, newValue: bool): bool
-    {.importc: "__sync_bool_compare_and_swap", nodecl.}
-
 # We declare our own condition variables here to get rid of the dummy lock
 # on Windows:
 
@@ -54,6 +30,9 @@ proc createCondVar(): CondVar =
     initSysLock(result.stupidLock)
     #acquireSys(result.stupidLock)
 
+proc destroyCondVar(c: var CondVar) {.inline.} =
+  deinitSysCond(c.c)
+
 proc await(cv: var CondVar) =
   when defined(posix):
     acquireSys(cv.stupidLock)
@@ -100,6 +79,26 @@ proc signal(cv: var FastCondVar) =
   #if cas(addr cv.slowPath, true, false):
   signal(cv.slow)
 
+type
+  Barrier* {.compilerProc.} = object
+    counter: int
+    cv: CondVar
+
+proc barrierEnter*(b: ptr Barrier) {.compilerProc.} =
+  atomicInc b.counter
+
+proc barrierLeave*(b: ptr Barrier) {.compilerProc.} =
+  atomicDec b.counter
+  if b.counter <= 0: signal(b.cv)
+
+proc openBarrier*(b: ptr Barrier) {.compilerProc.} =
+  b.counter = 0
+  b.cv = createCondVar()
+
+proc closeBarrier*(b: ptr Barrier) {.compilerProc.} =
+  await(b.cv)
+  destroyCondVar(b.cv)
+
 {.pop.}
 
 # ----------------------------------------------------------------------------
diff --git a/lib/system/threads.nim b/lib/system/threads.nim
index 0d52e4d09..d3b3aa457 100644
--- a/lib/system/threads.nim
+++ b/lib/system/threads.nim
@@ -243,7 +243,7 @@ when not defined(useNimRtl):
       
     # on UNIX, the GC uses ``SIGFREEZE`` to tell every thread to stop so that
     # the GC can examine the stacks?
-    proc stopTheWord() = nil
+    proc stopTheWord() = discard
     
 # We jump through some hops here to ensure that Nimrod thread procs can have
 # the Nimrod calling convention. This is needed because thread procs are 
diff --git a/lib/windows/windows.nim b/lib/windows/windows.nim
index dd743ffa4..5fd9127b3 100644
--- a/lib/windows/windows.nim
+++ b/lib/windows/windows.nim
@@ -62,7 +62,7 @@ type  # BaseTsd.h -- Type definitions for the basic sized types
 

 type  # WinDef.h -- Basic Windows Type Definitions

   # BaseTypes

-  UINT = int32
+  WINUINT* = int32

   ULONG* = int

   PULONG* = ptr int

   USHORT* = int16

@@ -137,7 +137,7 @@ type  # WinDef.h -- Basic Windows Type Definitions
 

   HFILE* = HANDLE

   HCURSOR* = HANDLE # = HICON

-  COLORREF* = int

+  COLORREF* = DWORD

   LPCOLORREF* = ptr COLORREF

 

   POINT* {.final, pure.} = object

@@ -238,7 +238,7 @@ type
   CALTYPE* = int

   CALID* = int

   CCHAR* = char

-  TCOLORREF* = int

+  TCOLORREF* = COLORREF

   WINT* = int32

   PINTEGER* = ptr int32

   PBOOL* = ptr WINBOOL

@@ -377,32 +377,32 @@ type
 #    Definitions for callback procedures

 #

 type

-  BFFCALLBACK* = proc (para1: HWND, para2: UINT, para3: LPARAM, para4: LPARAM): int32{.

+  BFFCALLBACK* = proc (para1: HWND, para2: WINUINT, para3: LPARAM, para4: LPARAM): int32{.

       stdcall.}

-  LPCCHOOKPROC* = proc (para1: HWND, para2: UINT, para3: WPARAM, para4: LPARAM): UINT{.

+  LPCCHOOKPROC* = proc (para1: HWND, para2: WINUINT, para3: WPARAM, para4: LPARAM): WINUINT{.

       stdcall.}

-  LPCFHOOKPROC* = proc (para1: HWND, para2: UINT, para3: WPARAM, para4: LPARAM): UINT{.

+  LPCFHOOKPROC* = proc (para1: HWND, para2: WINUINT, para3: WPARAM, para4: LPARAM): WINUINT{.

       stdcall.}

   PTHREAD_START_ROUTINE* = Pointer

   LPTHREAD_START_ROUTINE* = PTHREAD_START_ROUTINE

   EDITSTREAMCALLBACK* = proc (para1: DWORD, para2: LPBYTE, para3: LONG,

                               para4: LONG): DWORD{.stdcall.}

-  LPFRHOOKPROC* = proc (para1: HWND, para2: UINT, para3: WPARAM, para4: LPARAM): UINT{.

+  LPFRHOOKPROC* = proc (para1: HWND, para2: WINUINT, para3: WPARAM, para4: LPARAM): WINUINT{.

       stdcall.}

-  LPOFNHOOKPROC* = proc (para1: HWND, para2: UINT, para3: WPARAM, para4: LPARAM): UINT{.

+  LPOFNHOOKPROC* = proc (para1: HWND, para2: WINUINT, para3: WPARAM, para4: LPARAM): WINUINT{.

       stdcall.}

-  LPPRINTHOOKPROC* = proc (para1: HWND, para2: UINT, para3: WPARAM,

-                           para4: LPARAM): UINT{.stdcall.}

-  LPSETUPHOOKPROC* = proc (para1: HWND, para2: UINT, para3: WPARAM,

-                           para4: LPARAM): UINT{.stdcall.}

-  DLGPROC* = proc (para1: HWND, para2: UINT, para3: WPARAM, para4: LPARAM): LRESULT{.

+  LPPRINTHOOKPROC* = proc (para1: HWND, para2: WINUINT, para3: WPARAM,

+                           para4: LPARAM): WINUINT{.stdcall.}

+  LPSETUPHOOKPROC* = proc (para1: HWND, para2: WINUINT, para3: WPARAM,

+                           para4: LPARAM): WINUINT{.stdcall.}

+  DLGPROC* = proc (para1: HWND, para2: WINUINT, para3: WPARAM, para4: LPARAM): LRESULT{.

       stdcall.}

-  PFNPROPSHEETCALLBACK* = proc (para1: HWND, para2: UINT, para3: LPARAM): int32{.

+  PFNPROPSHEETCALLBACK* = proc (para1: HWND, para2: WINUINT, para3: LPARAM): int32{.

       stdcall.}

   LPSERVICE_MAIN_FUNCTION* = proc (para1: DWORD, para2: LPTSTR){.stdcall.}

   PFNTVCOMPARE* = proc (para1: LPARAM, para2: LPARAM, para3: LPARAM): int32{.

       stdcall.}

-  WNDPROC* = proc (para1: HWND, para2: UINT, para3: WPARAM, para4: LPARAM): LRESULT{.

+  WNDPROC* = proc (para1: HWND, para2: WINUINT, para3: WPARAM, para4: LPARAM): LRESULT{.

       stdcall.}

   FARPROC* = pointer

   TFarProc* = FARPROC

@@ -416,9 +416,9 @@ type
   DESKTOPENUMPROC* = FARPROC

   ENUMWINDOWSPROC* = proc (para1: HWND, para2: LPARAM): WINBOOL{.stdcall.}

   ENUMWINDOWSTATIONPROC* = proc (para1: LPTSTR, para2: LPARAM): WINBOOL{.stdcall.}

-  SENDASYNCPROC* = proc (para1: HWND, para2: UINT, para3: DWORD, para4: LRESULT){.

+  SENDASYNCPROC* = proc (para1: HWND, para2: WINUINT, para3: DWORD, para4: LRESULT){.

       stdcall.}

-  TIMERPROC* = proc (para1: HWND, para2: UINT, para3: UINT, para4: DWORD){.

+  TIMERPROC* = proc (para1: HWND, para2: WINUINT, para3: WINUINT, para4: DWORD){.

       stdcall.}

   GRAYSTRINGPROC* = FARPROC

   DRAWSTATEPROC* = proc (para1: HDC, para2: LPARAM, para3: WPARAM, para4: int32,

@@ -432,10 +432,10 @@ type
   ENUMOBJECTSPROC* = proc (para1: LPVOID, para2: LPARAM){.stdcall.}

   LINEDDAPROC* = proc (para1: int32, para2: int32, para3: LPARAM){.stdcall.}

   TABORTPROC* = proc (para1: HDC, para2: int32): WINBOOL{.stdcall.}

-  LPPAGEPAINTHOOK* = proc (para1: HWND, para2: UINT, para3: WPARAM,

-                           para4: LPARAM): UINT{.stdcall.}

-  LPPAGESETUPHOOK* = proc (para1: HWND, para2: UINT, para3: WPARAM,

-                           para4: LPARAM): UINT{.stdcall.}

+  LPPAGEPAINTHOOK* = proc (para1: HWND, para2: WINUINT, para3: WPARAM,

+                           para4: LPARAM): WINUINT{.stdcall.}

+  LPPAGESETUPHOOK* = proc (para1: HWND, para2: WINUINT, para3: WPARAM,

+                           para4: LPARAM): WINUINT{.stdcall.}

   ICMENUMPROC* = proc (para1: LPTSTR, para2: LPARAM): int32{.stdcall.}

   EDITWORDBREAKPROCEX* = proc (para1: cstring, para2: LONG, para3: int8,

                                para4: WINT): LONG{.stdcall.}

@@ -448,9 +448,9 @@ type
   CALINFO_ENUMPROC* = proc (para1: LPTSTR): WINBOOL{.stdcall.}

   PHANDLER_ROUTINE* = proc (para1: DWORD): WINBOOL{.stdcall.}

   LPHANDLER_FUNCTION* = proc (para1: DWORD): WINBOOL{.stdcall.}

-  PFNGETPROFILEPATH* = proc (para1: LPCTSTR, para2: LPSTR, para3: UINT): UINT{.

+  PFNGETPROFILEPATH* = proc (para1: LPCTSTR, para2: LPSTR, para3: WINUINT): WINUINT{.

       stdcall.}

-  PFNRECONCILEPROFILE* = proc (para1: LPCTSTR, para2: LPCTSTR, para3: DWORD): UINT{.

+  PFNRECONCILEPROFILE* = proc (para1: LPCTSTR, para2: LPCTSTR, para3: DWORD): WINUINT{.

       stdcall.}

   PFNPROCESSPOLICIES* = proc (para1: HWND, para2: LPCTSTR, para3: LPCTSTR,

                               para4: LPCTSTR, para5: DWORD): WINBOOL{.stdcall.}

@@ -498,7 +498,7 @@ else:
     SERVICES_FAILED_DATABASE* = SERVICES_FAILED_DATABASEA

     SC_GROUP_IDENTIFIER* = SC_GROUP_IDENTIFIERA

 type

-  PFNCALLBACK* = proc (para1, para2: UINT, para3: HCONV, para4, para5: HSZ,

+  PFNCALLBACK* = proc (para1, para2: WINUINT, para3: HCONV, para4, para5: HSZ,

                        para6: HDDEDATA, para7, para8: DWORD): HDDEData{.stdcall.}

   CALLB* = PFNCALLBACK

   SECURITY_CONTEXT_TRACKING_MODE* = WINBOOL

@@ -6872,7 +6872,7 @@ type
   va_list* = cstring

   TABC* {.final, pure.} = object

     abcA*: int32

-    abcB*: UINT

+    abcB*: WINUINT

     abcC*: int32

 

   LPABC* = ptr TABC

@@ -6913,7 +6913,7 @@ type
 

   TACCESS_DENIED_ACE* = ACCESS_DENIED_ACE

   ACCESSTIMEOUT* {.final, pure.} = object

-    cbSize*: UINT

+    cbSize*: WINUINT

     dwFlags*: DWORD

     iTimeOutMSec*: DWORD

 

@@ -6982,7 +6982,7 @@ type
   TADDJOB_INFO_1* = ADDJOB_INFO_1

   PADDJOB_INFO_1* = ptr ADDJOB_INFO_1

   ANIMATIONINFO* {.final, pure.} = object

-    cbSize*: UINT

+    cbSize*: WINUINT

     iMinAnimate*: int32

 

   LPANIMATIONINFO* = ptr ANIMATIONINFO

@@ -6992,8 +6992,8 @@ type
   APPBARDATA* {.final, pure.} = object

     cbSize*: DWORD

     hWnd*: HWND

-    uCallbackMessage*: UINT

-    uEdge*: UINT

+    uCallbackMessage*: WINUINT

+    uEdge*: WINUINT

     rc*: RECT

     lParam*: LPARAM

 

@@ -7147,7 +7147,7 @@ type
     pidlRoot*: LPCITEMIDLIST

     pszDisplayName*: LPSTR

     lpszTitle*: LPCSTR

-    ulFlags*: UINT

+    ulFlags*: WINUINT

     lpfn*: BFFCALLBACK

     lParam*: LPARAM

     iImage*: int32

@@ -7244,7 +7244,7 @@ type
   TCHAR_INFO* = CHAR_INFO

   PCHAR_INFO* = ptr CHAR_INFO

   CHARFORMAT* {.final, pure.} = object

-    cbSize*: UINT

+    cbSize*: WINUINT

     dwMask*: DWORD

     dwEffects*: DWORD

     yHeight*: LONG

@@ -7276,8 +7276,8 @@ type
   TFONTSIGNATURE* = FONTSIGNATURE

   PFONTSIGNATURE* = ptr FONTSIGNATURE

   CHARSETINFO* {.final, pure.} = object

-    ciCharset*: UINT

-    ciACP*: UINT

+    ciCharset*: WINUINT

+    ciACP*: WINUINT

     fs*: FONTSIGNATURE

 

   LPCHARSETINFO* = ptr CHARSETINFO

@@ -7359,15 +7359,15 @@ type
   LPCHOOSEFONT* = ptr TCHOOSEFONT

   PCHOOSEFONT* = ptr TCHOOSEFONT

   CIDA* {.final, pure.} = object

-    cidl*: UINT

-    aoffset*: array[0..0, UINT]

+    cidl*: WINUINT

+    aoffset*: array[0..0, WINUINT]

 

   LPIDA* = ptr CIDA

   TIDA* = CIDA

   PIDA* = ptr CIDA

   CLIENTCREATESTRUCT* {.final, pure.} = object

     hWindowMenu*: HANDLE

-    idFirstChild*: UINT

+    idFirstChild*: WINUINT

 

   LPCLIENTCREATESTRUCT* = ptr CLIENTCREATESTRUCT

   TCLIENTCREATESTRUCT* = CLIENTCREATESTRUCT

@@ -7537,12 +7537,12 @@ type
   TCOMMTIMEOUTS* = COMMTIMEOUTS

   PCOMMTIMEOUTS* = ptr COMMTIMEOUTS

   COMPAREITEMSTRUCT* {.final, pure.} = object

-    CtlType*: UINT

-    CtlID*: UINT

+    CtlType*: WINUINT

+    CtlID*: WINUINT

     hwndItem*: HWND

-    itemID1*: UINT

+    itemID1*: WINUINT

     itemData1*: ULONG_PTR

-    itemID2*: UINT

+    itemID2*: WINUINT

     itemData2*: ULONG_PTR

 

   TCOMPAREITEMSTRUCT* = COMPAREITEMSTRUCT

@@ -7936,9 +7936,9 @@ type
   PSECURITY_QUALITY_OF_SERVICE* = ptr SECURITY_QUALITY_OF_SERVICE

   TSECURITYQUALITYOFSERVICE* = SECURITY_QUALITY_OF_SERVICE

   CONVCONTEXT* {.final, pure.} = object

-    cb*: UINT

-    wFlags*: UINT

-    wCountryID*: UINT

+    cb*: WINUINT

+    wFlags*: WINUINT

+    wCountryID*: WINUINT

     iCodePage*: int32

     dwLangID*: DWORD

     dwSecurity*: DWORD

@@ -7954,11 +7954,11 @@ type
     hszServiceReq*: HSZ

     hszTopic*: HSZ

     hszItem*: HSZ

-    wFmt*: UINT

-    wType*: UINT

-    wStatus*: UINT

-    wConvst*: UINT

-    wLastError*: UINT

+    wFmt*: WINUINT

+    wType*: WINUINT

+    wStatus*: WINUINT

+    wConvst*: WINUINT

+    wLastError*: WINUINT

     hConvList*: HCONVLIST

     ConvCtxt*: CONVCONTEXT

     hwnd*: HWND

@@ -7974,7 +7974,7 @@ type
   TCOPYDATASTRUCT* = COPYDATASTRUCT

   PCOPYDATASTRUCT* = ptr COPYDATASTRUCT

   CPINFO* {.final, pure.} = object

-    MaxCharSize*: UINT

+    MaxCharSize*: WINUINT

     DefaultChar*: array[0..(MAX_DEFAULTCHAR) - 1, int8]

     LeadByte*: array[0..(MAX_LEADBYTES) - 1, int8]

 

@@ -8012,13 +8012,13 @@ type
   PCREATETHREADDEBUGINFO* = ptr CREATE_THREAD_DEBUG_INFO

 

   CURRENCYFMT* {.final, pure.} = object

-    NumDigits*: UINT

-    LeadingZero*: UINT

-    Grouping*: UINT

+    NumDigits*: WINUINT

+    LeadingZero*: WINUINT

+    Grouping*: WINUINT

     lpDecimalSep*: LPTSTR

     lpThousandSep*: LPTSTR

-    NegativeOrder*: UINT

-    PositiveOrder*: UINT

+    NegativeOrder*: WINUINT

+    PositiveOrder*: WINUINT

     lpCurrencySymbol*: LPTSTR

 

   Tcurrencyfmt* = CURRENCYFMT

@@ -8047,7 +8047,7 @@ type
   CWPSTRUCT* {.final, pure.} = object

     lParam*: LPARAM

     wParam*: WPARAM

-    message*: UINT

+    message*: WINUINT

     hwnd*: HWND

 

   TCWPSTRUCT* = CWPSTRUCT

@@ -8161,8 +8161,8 @@ proc fAckReq*(a: var DDELN): int16
 proc set_fAckReq*(a: var DDELN, fAckReq: int16)

 type

   DDEML_MSG_HOOK_DATA* {.final, pure.} = object

-    uiLo*: UINT

-    uiHi*: UINT

+    uiLo*: WINUINT

+    uiHi*: WINUINT

     cbData*: DWORD

     Data*: array[0..7, DWORD]

 

@@ -8329,9 +8329,9 @@ type
   TDEBUGHOOKINFO* = DEBUGHOOKINFO

   PDEBUGHOOKINFO* = ptr DEBUGHOOKINFO

   DELETEITEMSTRUCT* {.final, pure.} = object

-    CtlType*: UINT

-    CtlID*: UINT

-    itemID*: UINT

+    CtlType*: WINUINT

+    CtlID*: WINUINT

+    itemID*: WINUINT

     hwndItem*: HWND

     itemData*: ULONG_PTR

 

@@ -8572,7 +8572,7 @@ type
   TDOCINFOA* = DOCINFO

   PDOCINFO* = ptr DOCINFO

   DRAGLISTINFO* {.final, pure.} = object

-    uNotification*: UINT

+    uNotification*: WINUINT

     hWnd*: HWND

     ptCursor*: POINT

 

@@ -8580,11 +8580,11 @@ type
   TDRAGLISTINFO* = DRAGLISTINFO

   PDRAGLISTINFO* = ptr DRAGLISTINFO

   DRAWITEMSTRUCT* {.final, pure.} = object

-    CtlType*: UINT

-    CtlID*: UINT

-    itemID*: UINT

-    itemAction*: UINT

-    itemState*: UINT

+    CtlType*: WINUINT

+    CtlID*: WINUINT

+    itemID*: WINUINT

+    itemAction*: WINUINT

+    itemState*: WINUINT

     hwndItem*: HWND

     hDC*: HDC

     rcItem*: RECT

@@ -8594,11 +8594,11 @@ type
   TDRAWITEMSTRUCT* = DRAWITEMSTRUCT

   PDRAWITEMSTRUCT* = ptr DRAWITEMSTRUCT

   DRAWTEXTPARAMS* {.final, pure.} = object

-    cbSize*: UINT

+    cbSize*: WINUINT

     iTabLength*: int32

     iLeftMargin*: int32

     iRightMargin*: int32

-    uiLengthDrawn*: UINT

+    uiLengthDrawn*: WINUINT

 

   LPDRAWTEXTPARAMS* = ptr DRAWTEXTPARAMS

   TDRAWTEXTPARAMS* = DRAWTEXTPARAMS

@@ -8720,7 +8720,7 @@ type
   TEMRBITBLT* = EMRBITBLT

   PEMRBITBLT* = ptr EMRBITBLT

   LOGBRUSH* {.final, pure.} = object

-    lbStyle*: UINT

+    lbStyle*: WINUINT

     lbColor*: COLORREF

     lbHatch*: LONG

 

@@ -8806,7 +8806,7 @@ type
   TEMRCREATEPALETTE* = EMRCREATEPALETTE

   PEMRCREATEPALETTE* = ptr EMRCREATEPALETTE

   LOGPEN* {.final, pure.} = object

-    lopnStyle*: UINT

+    lopnStyle*: WINUINT

     lopnWidth*: POINT

     lopnColor*: COLORREF

 

@@ -8881,9 +8881,9 @@ type
   TEMREXTCREATEFONTINDIRECTW* = EMREXTCREATEFONTINDIRECTW

   PEMREXTCREATEFONTINDIRECTW* = ptr EMREXTCREATEFONTINDIRECTW

   EXTLOGPEN* {.final, pure.} = object

-    elpPenStyle*: UINT

-    elpWidth*: UINT

-    elpBrushStyle*: UINT

+    elpPenStyle*: WINUINT

+    elpWidth*: WINUINT

+    elpBrushStyle*: WINUINT

     elpColor*: COLORREF

     elpHatch*: LONG

     elpNumEntries*: DWORD

@@ -9424,8 +9424,8 @@ type
   PEMRENABLEICM* = ptr EMRSELECTCLIPPATH

   NMHDR* {.final, pure.} = object

     hwndFrom*: HWND

-    idFrom*: UINT

-    code*: UINT

+    idFrom*: WINUINT

+    code*: WINUINT

 

   TNMHDR* = NMHDR

   PNMHDR* = ptr NMHDR

@@ -9483,7 +9483,7 @@ type
   PENHMETARECORD* = ptr TENHMETARECORD

   TENPROTECTED* {.final, pure.} = object

     nmhdr*: NMHDR

-    msg*: UINT

+    msg*: WINUINT

     wParam*: WPARAM

     lParam*: LPARAM

     chrg*: CHARRANGE

@@ -9546,9 +9546,9 @@ type
   TEVENTLOGRECORD* = EVENTLOGRECORD

   PEVENTLOGRECORD* = ptr EVENTLOGRECORD

   EVENTMSG* {.final, pure.} = object

-    message*: UINT

-    paramL*: UINT

-    paramH*: UINT

+    message*: WINUINT

+    paramL*: WINUINT

+    paramH*: WINUINT

     time*: DWORD

     hwnd*: HWND

 

@@ -9570,7 +9570,7 @@ type
   TEXTBUTTON* = EXT_BUTTON

   PEXTBUTTON* = ptr EXT_BUTTON

   FILTERKEYS* {.final, pure.} = object

-    cbSize*: UINT

+    cbSize*: WINUINT

     dwFlags*: DWORD

     iWaitMSec*: DWORD

     iDelayMSec*: DWORD

@@ -9646,7 +9646,7 @@ type
     dwSize*: DWORD

     szMenuName*: array[0..(MENU_TEXT_LEN) - 1, TCHAR]

     hMenu*: HMENU

-    wMenuDelta*: UINT

+    wMenuDelta*: WINUINT

 

   TFMSLOAD* = FMS_LOAD

   PFMSLOAD* = ptr FMS_LOAD

@@ -9694,13 +9694,13 @@ type
   GCP_RESULTS* {.final, pure.} = object

     lStructSize*: DWORD

     lpOutString*: LPTSTR

-    lpOrder*: ptr UINT

+    lpOrder*: ptr WINUINT

     lpDx*: ptr WINT

     lpCaretPos*: ptr WINT

     lpClass*: LPTSTR

-    lpGlyphs*: ptr UINT

-    nGlyphs*: UINT

-    nMaxFit*: UINT

+    lpGlyphs*: ptr WINUINT

+    nGlyphs*: WINUINT

+    nMaxFit*: WINUINT

 

   LPGCP_RESULTS* = ptr GCP_RESULTS

   TGCPRESULTS* = GCP_RESULTS

@@ -9714,8 +9714,8 @@ type
   PGENERIC_MAPPING* = ptr GENERIC_MAPPING

   TGENERICMAPPING* = GENERIC_MAPPING

   GLYPHMETRICS* {.final, pure.} = object

-    gmBlackBoxX*: UINT

-    gmBlackBoxY*: UINT

+    gmBlackBoxX*: WINUINT

+    gmBlackBoxY*: WINUINT

     gmptGlyphOrigin*: POINT

     gmCellIncX*: SHORT

     gmCellIncY*: SHORT

@@ -9730,13 +9730,13 @@ type
   LPHANDLETABLE* = ptr HANDLETABLE

   HD_HITTESTINFO* {.final, pure.} = object

     pt*: POINT

-    flags*: UINT

+    flags*: WINUINT

     iItem*: int32

 

   THDHITTESTINFO* = HD_HITTESTINFO

   PHDHITTESTINFO* = ptr HD_HITTESTINFO

   HD_ITEM* {.final, pure.} = object

-    mask*: UINT

+    mask*: WINUINT

     cxy*: int32

     pszText*: LPTSTR

     hbm*: HBITMAP

@@ -9753,7 +9753,7 @@ type
     y*: int32

     cx*: int32

     cy*: int32

-    flags*: UINT

+    flags*: WINUINT

 

   LPWINDOWPOS* = ptr WINDOWPOS

   TWINDOWPOS* = WINDOWPOS

@@ -9773,7 +9773,7 @@ type
   THDNOTIFY* = HD_NOTIFY

   PHDNOTIFY* = ptr HD_NOTIFY

   HELPINFO* {.final, pure.} = object

-    cbSize*: UINT

+    cbSize*: WINUINT

     iContextType*: int32

     iCtrlId*: int32

     hItemHandle*: HANDLE

@@ -9795,7 +9795,7 @@ type
   THELPWININFO* = HELPWININFO

   PHELPWININFO* = ptr HELPWININFO

   HIGHCONTRAST* {.final, pure.} = object

-    cbSize*: UINT

+    cbSize*: WINUINT

     dwFlags*: DWORD

     lpszDefaultScheme*: LPTSTR

 

@@ -9818,7 +9818,7 @@ type
   TICONINFO* = ICONINFO

   PICONINFO* = ptr ICONINFO

   ICONMETRICS* {.final, pure.} = object

-    cbSize*: UINT

+    cbSize*: WINUINT

     iHorzSpacing*: int32

     iVertSpacing*: int32

     iTitleWrap*: int32

@@ -9860,7 +9860,7 @@ type
   TWINDOWBUFFERSIZERECORD* = WINDOW_BUFFER_SIZE_RECORD

   PWINDOWBUFFERSIZERECORD* = ptr WINDOW_BUFFER_SIZE_RECORD

   MENU_EVENT_RECORD* {.final, pure.} = object

-    dwCommandId*: UINT

+    dwCommandId*: WINUINT

 

   PMENU_EVENT_RECORD* = ptr MENU_EVENT_RECORD

   TMENUEVENTRECORD* = MENU_EVENT_RECORD

@@ -10039,7 +10039,7 @@ type
   PLUID_AND_ATTRIBUTES_ARRAY* = ptr LUID_AND_ATTRIBUTES_ARRAY

   TLUIDANDATTRIBUTESARRAY* = LUID_AND_ATTRIBUTES_ARRAY

   LV_COLUMN* {.final, pure.} = object

-    mask*: UINT

+    mask*: WINUINT

     fmt*: int32

     cx*: int32

     pszText*: LPTSTR

@@ -10049,11 +10049,11 @@ type
   TLVCOLUMN* = LV_COLUMN

   PLVCOLUMN* = ptr LV_COLUMN

   LV_ITEM* {.final, pure.} = object

-    mask*: UINT

+    mask*: WINUINT

     iItem*: int32

     iSubItem*: int32

-    state*: UINT

-    stateMask*: UINT

+    state*: WINUINT

+    stateMask*: WINUINT

     pszText*: LPTSTR

     cchTextMax*: int32

     iImage*: int32

@@ -10068,17 +10068,17 @@ type
   TLVDISPINFO* = LV_DISPINFO

   PLVDISPINFO* = ptr LV_DISPINFO

   LV_FINDINFO* {.final, pure.} = object

-    flags*: UINT

+    flags*: WINUINT

     psz*: LPCTSTR

     lParam*: LPARAM

     pt*: POINT

-    vkDirection*: UINT

+    vkDirection*: WINUINT

 

   TLVFINDINFO* = LV_FINDINFO

   PLVFINDINFO* = ptr LV_FINDINFO

   LV_HITTESTINFO* {.final, pure.} = object

     pt*: POINT

-    flags*: UINT

+    flags*: WINUINT

     iItem*: int32

 

   TLVHITTESTINFO* = LV_HITTESTINFO

@@ -10086,7 +10086,7 @@ type
   LV_KEYDOWN* {.final, pure.} = object

     hdr*: NMHDR

     wVKey*: int16

-    flags*: UINT

+    flags*: WINUINT

 

   TLVKEYDOWN* = LV_KEYDOWN

   PLVKEYDOWN* = ptr LV_KEYDOWN

@@ -10113,11 +10113,11 @@ type
   TMDICREATESTRUCT* = MDICREATESTRUCT

   PMDICREATESTRUCT* = ptr MDICREATESTRUCT

   MEASUREITEMSTRUCT* {.final, pure.} = object

-    CtlType*: UINT

-    CtlID*: UINT

-    itemID*: UINT

-    itemWidth*: UINT

-    itemHeight*: UINT

+    CtlType*: WINUINT

+    CtlID*: WINUINT

+    itemID*: WINUINT

+    itemWidth*: WINUINT

+    itemHeight*: WINUINT

     itemData*: ULONG_PTR

 

   LPMEASUREITEMSTRUCT* = ptr MEASUREITEMSTRUCT

@@ -10163,7 +10163,7 @@ type
   MENUEX_TEMPLATE_ITEM* {.final, pure.} = object

     dwType*: DWORD

     dwState*: DWORD

-    uId*: UINT

+    uId*: WINUINT

     bResInfo*: int8

     szText*: array[0..0, WCHAR]

     dwHelpId*: DWORD

@@ -10174,7 +10174,7 @@ type
     cbSize*: DWORD

     fMask*: DWORD

     dwStyle*: DWORD

-    cyMax*: UINT

+    cyMax*: WINUINT

     hbrBack*: HBRUSH

     dwContextHelpID*: DWORD

     dwMenuData*: ULONG_PTR

@@ -10184,17 +10184,17 @@ type
   TMENUINFO* = MENUINFO

   PMENUINFO* = ptr MENUINFO

   MENUITEMINFO* {.final, pure.} = object

-    cbSize*: UINT

-    fMask*: UINT

-    fType*: UINT

-    fState*: UINT

-    wID*: UINT

+    cbSize*: WINUINT

+    fMask*: WINUINT

+    fType*: WINUINT

+    fState*: WINUINT

+    wID*: WINUINT

     hSubMenu*: HMENU

     hbmpChecked*: HBITMAP

     hbmpUnchecked*: HBITMAP

     dwItemData*: ULONG_PTR

     dwTypeData*: LPTSTR

-    cch*: UINT

+    cch*: WINUINT

     hbmpItem*: HBITMAP

 

   LPMENUITEMINFO* = ptr MENUITEMINFO

@@ -10248,7 +10248,7 @@ type
   TMETARECORD* = METARECORD

   PMETARECORD* = ptr METARECORD

   MINIMIZEDMETRICS* {.final, pure.} = object

-    cbSize*: UINT

+    cbSize*: WINUINT

     iWidth*: int32

     iHorzGap*: int32

     iVertGap*: int32

@@ -10309,12 +10309,12 @@ type
   TMODEMSETTINGS* = MODEMSETTINGS

   PMODEMSETTINGS* = ptr MODEMSETTINGS

   MONCBSTRUCT* {.final, pure.} = object

-    cb*: UINT

+    cb*: WINUINT

     dwTime*: DWORD

     hTask*: HANDLE

     dwRet*: DWORD

-    wType*: UINT

-    wFmt*: UINT

+    wType*: WINUINT

+    wFmt*: WINUINT

     hConv*: HCONV

     hsz1*: HSZ

     hsz2*: HSZ

@@ -10328,7 +10328,7 @@ type
   TMONCBSTRUCT* = MONCBSTRUCT

   PMONCBSTRUCT* = ptr MONCBSTRUCT

   MONCONVSTRUCT* {.final, pure.} = object

-    cb*: UINT

+    cb*: WINUINT

     fConnect*: WINBOOL

     dwTime*: DWORD

     hTask*: HANDLE

@@ -10340,15 +10340,15 @@ type
   TMONCONVSTRUCT* = MONCONVSTRUCT

   PMONCONVSTRUCT* = ptr MONCONVSTRUCT

   MONERRSTRUCT* {.final, pure.} = object

-    cb*: UINT

-    wLastError*: UINT

+    cb*: WINUINT

+    wLastError*: WINUINT

     dwTime*: DWORD

     hTask*: HANDLE

 

   TMONERRSTRUCT* = MONERRSTRUCT

   PMONERRSTRUCT* = ptr MONERRSTRUCT

   MONHSZSTRUCT* {.final, pure.} = object

-    cb*: UINT

+    cb*: WINUINT

     fsAction*: WINBOOL

     dwTime*: DWORD

     hsz*: HSZ

@@ -10370,7 +10370,7 @@ type
   TMONITORINFO2* = MONITOR_INFO_2

   PMONITORINFO2* = ptr MONITOR_INFO_2

   MONLINKSTRUCT* {.final, pure.} = object

-    cb*: UINT

+    cb*: WINUINT

     dwTime*: DWORD

     hTask*: HANDLE

     fEstablished*: WINBOOL

@@ -10378,7 +10378,7 @@ type
     hszSvc*: HSZ

     hszTopic*: HSZ

     hszItem*: HSZ

-    wFmt*: UINT

+    wFmt*: WINUINT

     fServer*: WINBOOL

     hConvServer*: HCONV

     hConvClient*: HCONV

@@ -10386,11 +10386,11 @@ type
   TMONLINKSTRUCT* = MONLINKSTRUCT

   PMONLINKSTRUCT* = ptr MONLINKSTRUCT

   MONMSGSTRUCT* {.final, pure.} = object

-    cb*: UINT

+    cb*: WINUINT

     hwndTo*: HWND

     dwTime*: DWORD

     hTask*: HANDLE

-    wMsg*: UINT

+    wMsg*: WINUINT

     wParam*: WPARAM

     lParam*: LPARAM

     dmhd*: DDEML_MSG_HOOK_DATA

@@ -10400,7 +10400,7 @@ type
   MOUSEHOOKSTRUCT* {.final, pure.} = object

     pt*: POINT

     hwnd*: HWND

-    wHitTestCode*: UINT

+    wHitTestCode*: WINUINT

     dwExtraInfo*: DWORD

 

   LPMOUSEHOOKSTRUCT* = ptr MOUSEHOOKSTRUCT

@@ -10420,7 +10420,7 @@ type
   MSGBOXCALLBACK* = proc (lpHelpInfo: LPHELPINFO){.stdcall.}

   TMSGBOXCALLBACK* = MSGBOXCALLBACK

   MSGBOXPARAMS* {.final, pure.} = object

-    cbSize*: UINT

+    cbSize*: WINUINT

     hwndOwner*: HWND

     hInstance*: HINST

     lpszText*: LPCSTR

@@ -10437,7 +10437,7 @@ type
   PMSGBOXPARAMS* = ptr MSGBOXPARAMS

   MSGFILTER* {.final, pure.} = object

     nmhdr*: NMHDR

-    msg*: UINT

+    msg*: WINUINT

     wParam*: WPARAM

     lParam*: LPARAM

 

@@ -10546,9 +10546,9 @@ type
     tmPitchAndFamily*: int8

     tmCharSet*: int8

     ntmFlags*: DWORD

-    ntmSizeEM*: UINT

-    ntmCellHeight*: UINT

-    ntmAvgWidth*: UINT

+    ntmSizeEM*: WINUINT

+    ntmCellHeight*: WINUINT

+    ntmAvgWidth*: WINUINT

 

   TNEWTEXTMETRIC* = NEWTEXTMETRIC

   PNEWTEXTMETRIC* = ptr NEWTEXTMETRIC

@@ -10562,19 +10562,19 @@ type
     hdr*: NMHDR

     iItem*: int32

     iSubItem*: int32

-    uNewState*: UINT

-    uOldState*: UINT

-    uChanged*: UINT

+    uNewState*: WINUINT

+    uOldState*: WINUINT

+    uChanged*: WINUINT

     ptAction*: POINT

     lParam*: LPARAM

 

   TNMLISTVIEW* = NM_LISTVIEW

   PNMLISTVIEW* = ptr NM_LISTVIEW

   TV_ITEM* {.final, pure.} = object

-    mask*: UINT

+    mask*: WINUINT

     hItem*: HTREEITEM

-    state*: UINT

-    stateMask*: UINT

+    state*: WINUINT

+    stateMask*: WINUINT

     pszText*: LPTSTR

     cchTextMax*: int32

     iImage*: int32

@@ -10587,7 +10587,7 @@ type
   PTVITEM* = ptr TV_ITEM

   NM_TREEVIEW* {.final, pure.} = object

     hdr*: NMHDR

-    action*: UINT

+    action*: WINUINT

     itemOld*: TV_ITEM

     itemNew*: TV_ITEM

     ptDrag*: POINT

@@ -10603,7 +10603,7 @@ type
   TNMUPDOWN* = NM_UPDOWNW

   PNMUPDOWN* = ptr NM_UPDOWNW

   NONCLIENTMETRICS* {.final, pure.} = object

-    cbSize*: UINT

+    cbSize*: WINUINT

     iBorderWidth*: int32

     iScrollWidth*: int32

     iScrollHeight*: int32

@@ -10666,12 +10666,12 @@ type
   TNSSERVICEINFO* = NS_SERVICE_INFO

   PNSSERVICEINFO* = ptr NS_SERVICE_INFO

   NUMBERFMT* {.final, pure.} = object

-    NumDigits*: UINT

-    LeadingZero*: UINT

-    Grouping*: UINT

+    NumDigits*: WINUINT

+    LeadingZero*: WINUINT

+    Grouping*: WINUINT

     lpDecimalSep*: LPTSTR

     lpThousandSep*: LPTSTR

-    NegativeOrder*: UINT

+    NegativeOrder*: WINUINT

 

   Tnumberfmt* = NUMBERFMT

   Pnumberfmt* = ptr NUMBERFMT

@@ -10821,31 +10821,31 @@ type
   TTEXTMETRICW* = TEXTMETRICW

   PTEXTMETRICW* = ptr TEXTMETRICW

   OUTLINETEXTMETRIC* {.final, pure.} = object

-    otmSize*: UINT

+    otmSize*: WINUINT

     otmTextMetrics*: TEXTMETRIC

     otmFiller*: int8

     otmPanoseNumber*: PANOSE

-    otmfsSelection*: UINT

-    otmfsType*: UINT

+    otmfsSelection*: WINUINT

+    otmfsType*: WINUINT

     otmsCharSlopeRise*: int32

     otmsCharSlopeRun*: int32

     otmItalicAngle*: int32

-    otmEMSquare*: UINT

+    otmEMSquare*: WINUINT

     otmAscent*: int32

     otmDescent*: int32

-    otmLineGap*: UINT

-    otmsCapEmHeight*: UINT

-    otmsXHeight*: UINT

+    otmLineGap*: WINUINT

+    otmsCapEmHeight*: WINUINT

+    otmsXHeight*: WINUINT

     otmrcFontBox*: RECT

     otmMacAscent*: int32

     otmMacDescent*: int32

-    otmMacLineGap*: UINT

-    otmusMinimumPPEM*: UINT

+    otmMacLineGap*: WINUINT

+    otmusMinimumPPEM*: WINUINT

     otmptSubscriptSize*: POINT

     otmptSubscriptOffset*: POINT

     otmptSuperscriptSize*: POINT

     otmptSuperscriptOffset*: POINT

-    otmsStrikeoutSize*: UINT

+    otmsStrikeoutSize*: WINUINT

     otmsStrikeoutPosition*: int32

     otmsUnderscoreSize*: int32

     otmsUnderscorePosition*: int32

@@ -10900,7 +10900,7 @@ type
   TPAINTSTRUCT* = PAINTSTRUCT

   PPAINTSTRUCT* = ptr PAINTSTRUCT

   PARAFORMAT* {.final, pure.} = object

-    cbSize*: UINT

+    cbSize*: WINUINT

     dwMask*: DWORD

     wNumbering*: int16

     wReserved*: int16

@@ -10981,9 +10981,9 @@ type
   POLYTEXT* {.final, pure.} = object

     x*: int32

     y*: int32

-    n*: UINT

+    n*: WINUINT

     lpstr*: LPCTSTR

-    uiFlags*: UINT

+    uiFlags*: WINUINT

     rcl*: RECT

     pdx*: ptr int32

 

@@ -11169,7 +11169,7 @@ type
   LPPROCESS_INFORMATION* = ptr PROCESS_INFORMATION

   TPROCESSINFORMATION* = PROCESS_INFORMATION

   PPROCESSINFORMATION* = ptr PROCESS_INFORMATION

-  LPFNPSPCALLBACK* = proc (para1: HWND, para2: UINT, para3: LPVOID): UINT{.

+  LPFNPSPCALLBACK* = proc (para1: HWND, para2: WINUINT, para3: LPVOID): WINUINT{.

       stdcall.}

   TFNPSPCALLBACK* = LPFNPSPCALLBACK

   PROPSHEETPAGE* {.final, pure.} = object

@@ -11181,7 +11181,7 @@ type
     pfnDlgProc*: DLGPROC

     lParam*: LPARAM

     pfnCallback*: LPFNPSPCALLBACK

-    pcRefParent*: ptr UINT

+    pcRefParent*: ptr WINUINT

 

   LPPROPSHEETPAGE* = ptr PROPSHEETPAGE

   LPCPROPSHEETPAGE* = ptr PROPSHEETPAGE

@@ -11197,7 +11197,7 @@ type
     hInstance*: HINST

     pszIcon*: LPCTSTR

     pszCaption*: LPCTSTR

-    nPages*: UINT

+    nPages*: WINUINT

     pStartPage*: LPCTSTR

     phpage*: ptr HPROPSHEETPAGE

     pfnCallback*: PFNPROPSHEETCALLBACK

@@ -11243,7 +11243,7 @@ type
   TPSHNOTIFY* = PSHNOTIFY

   PPSHNOTIFY* = ptr PSHNOTIFY

   PUNCTUATION* {.final, pure.} = object

-    iSize*: UINT

+    iSize*: WINUINT

     szPunctuation*: LPSTR

 

   Tpunctuation* = PUNCTUATION

@@ -11395,11 +11395,11 @@ type
   TRGNDATA* = RGNDATA

   PRGNDATA* = ptr RGNDATA

   SCROLLINFO* {.final, pure.} = object

-    cbSize*: UINT

-    fMask*: UINT

+    cbSize*: WINUINT

+    fMask*: WINUINT

     nMin*: int32

     nMax*: int32

-    nPage*: UINT

+    nPage*: WINUINT

     nPos*: int32

     nTrackPos*: int32

 

@@ -11499,7 +11499,7 @@ type
   PFILEOPFLAGS* = ptr FILEOP_FLAGS

   SHFILEOPSTRUCT* {.final, pure.} = object

     hwnd*: HWND

-    wFunc*: UINT

+    wFunc*: WINUINT

     pFrom*: LPCSTR

     pTo*: LPCSTR

     fFlags*: FILEOP_FLAGS

@@ -11537,7 +11537,7 @@ type
   TSINGLELISTENTRY* = SINGLE_LIST_ENTRY

   PSINGLELISTENTRY* = ptr SINGLE_LIST_ENTRY

   SOUNDSENTRY* {.final, pure.} = object

-    cbSize*: UINT

+    cbSize*: WINUINT

     dwFlags*: DWORD

     iFSTextEffect*: DWORD

     iFSTextEffectMSec*: DWORD

@@ -11584,7 +11584,7 @@ type
   TSTICKYKEYS* = STICKYKEYS

   PSTICKYKEYS* = ptr STICKYKEYS

   STRRET* {.final, pure.} = object

-    uType*: UINT

+    uType*: WINUINT

     cStr*: array[0..(MAX_PATH) - 1, char]

 

   LPSTRRET* = ptr STRRET

@@ -11709,7 +11709,7 @@ type
   PTAPEWRITEMARKS* = ptr TAPE_WRITE_MARKS

   TTBADDBITMAP* {.final, pure.} = object

     hInst*: HINST

-    nID*: UINT

+    nID*: WINUINT

 

   LPTBADDBITMAP* = ptr TTBADDBITMAP

   PTBADDBITMAP* = ptr TTBADDBITMAP

@@ -11744,14 +11744,14 @@ type
   PTBSAVEPARAMS* = ptr TBSAVEPARAMS

   TC_HITTESTINFO* {.final, pure.} = object

     pt*: POINT

-    flags*: UINT

+    flags*: WINUINT

 

   TTCHITTESTINFO* = TC_HITTESTINFO

   PTCHITTESTINFO* = ptr TC_HITTESTINFO

   TC_ITEM* {.final, pure.} = object

-    mask*: UINT

-    lpReserved1*: UINT

-    lpReserved2*: UINT

+    mask*: WINUINT

+    lpReserved1*: WINUINT

+    lpReserved2*: WINUINT

     pszText*: LPTSTR

     cchTextMax*: int32

     iImage*: int32

@@ -11760,9 +11760,9 @@ type
   TTCITEM* = TC_ITEM

   PTCITEM* = ptr TC_ITEM

   TC_ITEMHEADER* {.final, pure.} = object

-    mask*: UINT

-    lpReserved1*: UINT

-    lpReserved2*: UINT

+    mask*: WINUINT

+    lpReserved1*: WINUINT

+    lpReserved2*: WINUINT

     pszText*: LPTSTR

     cchTextMax*: int32

     iImage*: int32

@@ -11772,7 +11772,7 @@ type
   TC_KEYDOWN* {.final, pure.} = object

     hdr*: NMHDR

     wVKey*: int16

-    flags*: UINT

+    flags*: WINUINT

 

   TTCKEYDOWN* = TC_KEYDOWN

   PTCKEYDOWN* = ptr TC_KEYDOWN

@@ -11855,10 +11855,10 @@ type
 

   PTOKENUSER* = ptr TTOKEN_USER

   TOOLINFO* {.final, pure.} = object

-    cbSize*: UINT

-    uFlags*: UINT

+    cbSize*: WINUINT

+    uFlags*: WINUINT

     hwnd*: HWND

-    uId*: UINT

+    uId*: WINUINT

     rect*: RECT

     hinst*: HINST

     lpszText*: LPTSTR

@@ -11871,13 +11871,13 @@ type
     lpszText*: LPTSTR

     szText*: array[0..79, char]

     hinst*: HINST

-    uFlags*: UINT

+    uFlags*: WINUINT

 

   LPTOOLTIPTEXT* = ptr TOOLTIPTEXT

   TTOOLTIPTEXT* = TOOLTIPTEXT

   PTOOLTIPTEXT* = ptr TOOLTIPTEXT

   TPMPARAMS* {.final, pure.} = object

-    cbSize*: UINT

+    cbSize*: WINUINT

     rcExclude*: RECT

 

   LPTPMPARAMS* = ptr TPMPARAMS

@@ -11923,7 +11923,7 @@ type
   PTVDISPINFO* = ptr TV_DISPINFO

   TV_HITTESTINFO* {.final, pure.} = object

     pt*: POINT

-    flags*: UINT

+    flags*: WINUINT

     hItem*: HTREEITEM

 

   LPTV_HITTESTINFO* = ptr TV_HITTESTINFO

@@ -11940,7 +11940,7 @@ type
   TV_KEYDOWN* {.final, pure.} = object

     hdr*: NMHDR

     wVKey*: int16

-    flags*: UINT

+    flags*: WINUINT

 

   TTVKEYDOWN* = TV_KEYDOWN

   PTVKEYDOWN* = ptr TV_KEYDOWN

@@ -11953,8 +11953,8 @@ type
   TTVSORTCB* = TV_SORTCB

   PTVSORTCB* = ptr TV_SORTCB

   UDACCEL* {.final, pure.} = object

-    nSec*: UINT

-    nInc*: UINT

+    nSec*: WINUINT

+    nInc*: WINUINT

 

   TUDACCEL* = UDACCEL

   PUDACCEL* = ptr UDACCEL

@@ -12045,9 +12045,9 @@ type
   TWIN32STREAMID* = WIN32_STREAM_ID

   PWIN32STREAMID* = ptr WIN32_STREAM_ID

   WINDOWPLACEMENT* {.final, pure.} = object

-    len*: UINT

-    flags*: UINT

-    showCmd*: UINT

+    len*: WINUINT

+    flags*: WINUINT

+    showCmd*: WINUINT

     ptMinPosition*: POINT

     ptMaxPosition*: POINT

     rcNormalPosition*: RECT

@@ -12055,7 +12055,7 @@ type
   TWINDOWPLACEMENT* = WINDOWPLACEMENT

   PWINDOWPLACEMENT* = ptr WINDOWPLACEMENT

   WNDCLASS* {.final, pure.} = object

-    style*: UINT

+    style*: WINUINT

     lpfnWndProc*: WNDPROC

     cbClsExtra*: int32

     cbWndExtra*: int32

@@ -12071,7 +12071,7 @@ type
   TWNDCLASSA* = WNDCLASS

   PWNDCLASS* = ptr WNDCLASS

   WNDCLASSW* {.final, pure.} = object

-    style*: UINT

+    style*: WINUINT

     lpfnWndProc*: WNDPROC

     cbClsExtra*: int32

     cbWndExtra*: int32

@@ -12086,8 +12086,8 @@ type
   TWNDCLASSW* = WNDCLASSW

   PWNDCLASSW* = ptr WNDCLASSW

   WNDCLASSEX* {.final, pure.} = object

-    cbSize*: UINT

-    style*: UINT

+    cbSize*: WINUINT

+    style*: WINUINT

     lpfnWndProc*: WNDPROC

     cbClsExtra*: int32

     cbWndExtra*: int32

@@ -12104,8 +12104,8 @@ type
   TWNDCLASSEXA* = WNDCLASSEX

   PWNDCLASSEX* = ptr WNDCLASSEX

   WNDCLASSEXW* {.final, pure.} = object

-    cbSize*: UINT

-    style*: UINT

+    cbSize*: WINUINT

+    style*: WINUINT

     lpfnWndProc*: WNDPROC

     cbClsExtra*: int32

     cbWndExtra*: int32

@@ -12362,9 +12362,9 @@ type
   NOTIFYICONDATAA* {.final, pure.} = object

     cbSize*: DWORD

     Wnd*: HWND

-    uID*: UINT

-    uFlags*: UINT

-    uCallbackMessage*: UINT

+    uID*: WINUINT

+    uFlags*: WINUINT

+    uCallbackMessage*: WINUINT

     hIcon*: HICON

     szTip*: array[0..63, Char]

 

@@ -12372,9 +12372,9 @@ type
   NOTIFYICONDATAW* {.final, pure.} = object

     cbSize*: DWORD

     Wnd*: HWND

-    uID*: UINT

-    uFlags*: UINT

-    uCallbackMessage*: UINT

+    uID*: WINUINT

+    uFlags*: WINUINT

+    uCallbackMessage*: WINUINT

     hIcon*: HICON

     szTip*: array[0..63, int16]

 

@@ -13519,7 +13519,7 @@ else:
 type

   MSG* {.final, pure.} = object

     hwnd*: HWND

-    message*: UINT

+    message*: WINUINT

     wParam*: WPARAM

     lParam*: LPARAM

     time*: DWORD

@@ -13530,20 +13530,20 @@ type
   PMSG* = ptr MSG

   PMessage* = ptr TMessage

   TMessage* {.final, pure.} = object          #fields according to ICS

-    msg*: UINT

+    msg*: WINUINT

     wParam*: WPARAM

     lParam*: LPARAM

     Result*: LRESULT

 

   TWMSize* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     SizeType*: WPARAM

     Width*: HALFPARAM

     Height*: HALFPARAM

     Result*: LRESULT

 

   TWMNoParams* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     Unused*: array[0..3, HALFPARAM]

     Result*: LRESULT

 

@@ -13553,7 +13553,7 @@ type
   TWMClose* = TWMNoParams

   TWMQueryUIState* = TWMNoParams

   TWMUIState* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     Action*: int16

     Flags*: int16

     Unused*: HRESULT

@@ -13561,7 +13561,7 @@ type
   TWMChangeUIState* = TWMUIState

   TWMUpdateUIState* = TWMUIState

   TWMKey* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     CharCode*: int16

     Unused*: int16

     KeyData*: int32

@@ -13574,7 +13574,7 @@ type
   TWMSysKeyDown* = TWMKey

   TWMSysKeyUp* = TWMKey

   TWMMenuChar* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     User*: Char

     MenuFlag*: int16

     Menu*: HMENU

@@ -13586,7 +13586,7 @@ type
   TWMSysColorChange* = TWMNoParams

   TWMQueryDragIcon* = TWMNoParams

   TWMScroll* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     ScrollCode*: HALFPARAM

     Pos*: HALFPARAM

     ScrollBar*: HWND

@@ -13595,59 +13595,59 @@ type
   TWMHScroll* = TWMScroll

   TWMVScroll* = TWMScroll

   TWMGetText* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     TextMax*: LPARAM

     Text*: cstring

     Result*: LRESULT

 

   TWMGetTextLength* = TWMNoParams

   TWMKillFocus* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     FocusedWnd*: HWND

     UnUsed*: WPARAM

     Result*: LRESULT

 

   TWMSetCursor* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     CursorWnd*: HWND

     HitTest*: HALFPARAM

     MouseMsg*: HALFPARAM

     Result*: LRESULT

 

   TWMSetFocus* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     FocusedWnd*: HWND

     Unused*: WPARAM

     Result*: LRESULT

 

   TWMSetFont* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     Font*: HFONT

     Redraw*: HALFPARAMBOOL

     Unused*: HALFPARAM

     Result*: LRESULT

 

   TWMShowWindow* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     Show*: HALFPARAMBOOL

     Unused*: HALFPARAM

     Status*: WPARAM

     Result*: LRESULT

 

   TWMEraseBkgnd* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     DC*: HDC

     Unused*: LPARAM

     Result*: LRESULT

 

   TWMNCHitTest* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     Unused*: int32

     Pos*: TSmallPoint

     Result*: LRESULT

 

   TWMMouse* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     Keys*: int32

     Pos*: TSmallPoint

     Result*: LRESULT

@@ -13659,14 +13659,14 @@ type
   TWMMButtonDown* = TWMMouse

   TWMMButtonUp* = TWMMouse

   TWMMouseWheel* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     Keys*: int16

     WheelDelta*: int16

     Pos*: TSmallPoint

     Result*: LRESULT

 

   TWMNCHitMessage* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     HitTest*: int32

     XCursor*: int16

     YCursor*: int16

@@ -13684,51 +13684,51 @@ type
   TWMRButtonUp* = TWMMouse

   TWMMouseMove* = TWMMouse

   TWMPaint* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     DC*: HDC

     Unused*: int32

     Result*: LRESULT

 

   TWMCommand* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     ItemID*: int16

     NotifyCode*: int16

     Ctl*: HWND

     Result*: LRESULT

 

   TWMNotify* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     IDCtrl*: int32

     NMHdr*: PNMHdr

     Result*: LRESULT

 

   TWMPrint* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     DC*: HDC

     Flags*: int

     Result*: LRESULT

 

   TWMPrintClient* = TWMPrint

   TWMWinIniChange* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     Unused*: int

     Section*: cstring

     Result*: LRESULT

 

   TWMContextMenu* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     hWnd*: HWND

     Pos*: TSmallPoint

     Result*: LRESULT

 

   TWMNCCalcSize* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     CalcValidRects*: WINBOOL

     CalcSize_Params*: PNCCalcSizeParams

     Result*: LRESULT

 

   TWMCharToItem* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     Key*: int16

     CaretPos*: int16

     ListBox*: HWND

@@ -13737,7 +13737,7 @@ type
   TWMVKeyToItem* = TWMCharToItem

   TMyEventRange = range[0'i16..16000'i16]

   TWMParentNotify* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     case Event*: TMyEventRange

     of TMyEventRange(WM_CREATE), TMyEventRange(WM_DESTROY):

         ChildID*: int16

@@ -13756,7 +13756,7 @@ type
         Result*: LRESULT

 

   TWMSysCommand* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     CmdType*: int32

     XPos*: int16

     YPos*: int16

@@ -13774,13 +13774,13 @@ type
   #      Key*: int16

 

   TWMMove* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     Unused*: int

     Pos*: TSmallPoint

     Result*: LRESULT

 

   TWMWindowPosMsg* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     Unused*: int

     WindowPos*: PWindowPos

     Result*: LRESULT

@@ -13788,101 +13788,101 @@ type
   TWMWindowPosChanged* = TWMWindowPosMsg

   TWMWindowPosChanging* = TWMWindowPosMsg

   TWMCompareItem* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     Ctl*: HWnd

     CompareItemStruct*: PCompareItemStruct

     Result*: LRESULT

 

   TWMDeleteItem* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     Ctl*: HWND

     DeleteItemStruct*: PDeleteItemStruct

     Result*: LRESULT

 

   TWMDrawItem* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     Ctl*: HWND

     DrawItemStruct*: PDrawItemStruct

     Result*: LRESULT

 

   TWMMeasureItem* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     IDCtl*: HWnd

     MeasureItemStruct*: PMeasureItemStruct

     Result*: LRESULT

 

   TWMNCCreate* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     Unused*: int

     CreateStruct*: PCreateStruct

     Result*: LRESULT

 

   TWMInitMenuPopup* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     MenuPopup*: HMENU

     Pos*: int16

     SystemMenu*: WordBool

     Result*: LRESULT

 

   TWMMenuSelect* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     IDItem*: int16

     MenuFlag*: int16

     Menu*: HMENU

     Result*: LRESULT

 

   TWMActivate* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     Active*: int16

     Minimized*: WordBool

     ActiveWindow*: HWND

     Result*: LRESULT

 

   TWMQueryEndSession* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     Source*: int32

     Unused*: int32

     Result*: LRESULT

 

   TWMMDIActivate* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     DeactiveWnd*: HWND

     ActiveWnd*: HWND

     Result*: LRESULT

 

   TWMNextDlgCtl* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     CtlFocus*: int32

     Handle*: WordBool

     Unused*: int16

     Result*: LRESULT

 

   TWMHelp* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     Unused*: int

     HelpInfo*: PHelpInfo

     Result*: LRESULT

 

   TWMGetMinMaxInfo* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     Unused*: int

     MinMaxInfo*: PMinMaxInfo

     Result*: LRESULT

 

   TWMSettingChange* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     Flag*: int

     Section*: cstring

     Result*: LRESULT

 

   TWMCreate* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     Unused*: int

     CreateStruct*: PCreateStruct

     Result*: LRESULT

 

   TWMCtlColor* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     ChildDC*: HDC

     ChildWnd*: HWND

     Result*: LRESULT

@@ -13895,38 +13895,38 @@ type
   TWMCtlColorDlg* = TWMCtlColor

   TWMCtlColorEdit* = TWMCtlColor

   TWMInitDialog* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     Focus*: HWND

     InitParam*: int32

     Result*: LRESULT

 

   TWMNCPaint* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     RGN*: HRGN

     Unused*: int32

     Result*: LRESULT

 

   TWMSetText* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     Unused*: int32

     Text*: cstring

     Result*: LRESULT

 

   TWMSizeClipboard* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     Viewer*: HWND

     RC*: THandle

     Result*: LRESULT

 

   TWMSpoolerStatus* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     JobStatus*: LPARAM

     JobsLeft*: WPARAM

     Unused*: WPARAM

     Result*: LRESULT

 

   TWMStyleChange* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     StyleType*: LPARAM

     StyleStruct*: PStyleStruct

     Result*: LRESULT

@@ -13934,42 +13934,42 @@ type
   TWMStyleChanged* = TWMStyleChange

   TWMStyleChanging* = TWMStyleChange

   TWMSysDeadChar* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     CharCode*: WPARAM

     Unused*: WPARAM

     KeyData*: LPARAM

     Result*: LRESULT

 

   TWMSystemError* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     ErrSpec*: WPARAM

     Unused*: LPARAM

     Result*: LRESULT

 

   TWMTimeChange* = TWMNoParams

   TWMTimer* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     TimerID*: LPARAM

     TimerProc*: TFarProc

     Result*: LRESULT

 

   TWMUndo* = TWMNoParams

   TWMVScrollClipboard* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     Viewer*: HWND

     ScollCode*: WPARAM

     ThumbPos*: WPARAM

     Result*: LRESULT

 

   TWMDisplayChange* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     BitsPerPixel*: int

     Width*: WPARAM

     Height*: WPARAM

     Result*: LRESULT

 

   TWMDropFiles* {.final, pure.} = object

-    Msg*: UINT

+    Msg*: WINUINT

     Drop*: THANDLE

     Unused*: LPARAM

     Result*: LRESULT

@@ -14042,7 +14042,7 @@ proc GetModuleFileNameA*(hModule: HINST, lpFilename: LPSTR, nSize: DWORD): DWORD
     stdcall, dynlib: "kernel32", importc.}

 proc GetModuleHandleA*(lpModuleName: LPCSTR): HMODULE{.stdcall,

      dynlib: "kernel32", importc.}

-proc FatalAppExitA*(uAction: UINT, lpMessageText: LPCSTR){.stdcall,

+proc FatalAppExitA*(uAction: WINUINT, lpMessageText: LPCSTR){.stdcall,

      dynlib: "kernel32", importc.}

 proc GetCommandLineA*(): LPSTR{.stdcall, dynlib: "kernel32", importc.}

 proc GetEnvironmentVariableA*(lpName: LPCSTR, lpBuffer: LPSTR, nSize: DWORD): DWORD{.

@@ -14080,15 +14080,15 @@ proc GlobalAddAtomA*(lpString: LPCSTR): ATOM{.stdcall, dynlib: "kernel32",
     importc: "GlobalAddAtomA".}

 proc GlobalFindAtomA*(lpString: LPCSTR): ATOM{.stdcall, dynlib: "kernel32",

     importc: "GlobalFindAtomA".}

-proc GlobalGetAtomNameA*(nAtom: ATOM, lpBuffer: LPSTR, nSize: int32): UINT{.

+proc GlobalGetAtomNameA*(nAtom: ATOM, lpBuffer: LPSTR, nSize: int32): WINUINT{.

     stdcall, dynlib: "kernel32", importc: "GlobalGetAtomNameA".}

 proc AddAtomA*(lpString: LPCSTR): ATOM{.stdcall, dynlib: "kernel32",

                                         importc: "AddAtomA".}

 proc FindAtomA*(lpString: LPCSTR): ATOM{.stdcall, dynlib: "kernel32",

     importc: "FindAtomA".}

-proc GetAtomNameA*(nAtom: ATOM, lpBuffer: LPSTR, nSize: int32): UINT{.stdcall,

+proc GetAtomNameA*(nAtom: ATOM, lpBuffer: LPSTR, nSize: int32): WINUINT{.stdcall,

     dynlib: "kernel32", importc: "GetAtomNameA".}

-proc GetProfileIntA*(lpAppName: LPCSTR, lpKeyName: LPCSTR, nDefault: WINT): UINT{.

+proc GetProfileIntA*(lpAppName: LPCSTR, lpKeyName: LPCSTR, nDefault: WINT): WINUINT{.

     stdcall, dynlib: "kernel32", importc: "GetProfileIntA".}

 proc GetProfileStringA*(lpAppName: LPCSTR, lpKeyName: LPCSTR, lpDefault: LPCSTR,

                         lpReturnedString: LPSTR, nSize: DWORD): DWORD{.stdcall,

@@ -14101,7 +14101,7 @@ proc GetProfileSectionA*(lpAppName: LPCSTR, lpReturnedString: LPSTR,
 proc WriteProfileSectionA*(lpAppName: LPCSTR, lpString: LPCSTR): WINBOOL{.

     stdcall, dynlib: "kernel32", importc: "WriteProfileSectionA".}

 proc GetPrivateProfileIntA*(lpAppName: LPCSTR, lpKeyName: LPCSTR,

-                            nDefault: WINT, lpFileName: LPCSTR): UINT{.stdcall,

+                            nDefault: WINT, lpFileName: LPCSTR): WINUINT{.stdcall,

     dynlib: "kernel32", importc: "GetPrivateProfileIntA".}

 proc GetPrivateProfileStringA*(lpAppName: LPCSTR, lpKeyName: LPCSTR,

                                lpDefault: LPCSTR, lpReturnedString: LPSTR,

@@ -14117,16 +14117,16 @@ proc GetPrivateProfileSectionA*(lpAppName: LPCSTR, lpReturnedString: LPSTR,
 proc WritePrivateProfileSectionA*(lpAppName: LPCSTR, lpString: LPCSTR,

                                   lpFileName: LPCSTR): WINBOOL{.stdcall,

     dynlib: "kernel32", importc: "WritePrivateProfileSectionA".}

-proc GetDriveTypeA*(lpRootPathName: LPCSTR): UINT{.stdcall, dynlib: "kernel32",

+proc GetDriveTypeA*(lpRootPathName: LPCSTR): WINUINT{.stdcall, dynlib: "kernel32",

     importc: "GetDriveTypeA".}

-proc GetSystemDirectoryA*(lpBuffer: LPSTR, uSize: UINT): UINT{.stdcall,

+proc GetSystemDirectoryA*(lpBuffer: LPSTR, uSize: WINUINT): WINUINT{.stdcall,

     dynlib: "kernel32", importc: "GetSystemDirectoryA".}

 proc GetTempPathA*(nBufferLength: DWORD, lpBuffer: LPSTR): DWORD{.stdcall,

     dynlib: "kernel32", importc: "GetTempPathA".}

 proc GetTempFileNameA*(lpPathName: LPCSTR, lpPrefixString: LPCSTR,

-                       uUnique: UINT, lpTempFileName: LPSTR): UINT{.stdcall,

+                       uUnique: WINUINT, lpTempFileName: LPSTR): WINUINT{.stdcall,

     dynlib: "kernel32", importc: "GetTempFileNameA".}

-proc GetWindowsDirectoryA*(lpBuffer: LPSTR, uSize: UINT): UINT{.stdcall,

+proc GetWindowsDirectoryA*(lpBuffer: LPSTR, uSize: WINUINT): WINUINT{.stdcall,

     dynlib: "kernel32", importc: "GetWindowsDirectoryA".}

 proc SetCurrentDirectoryA*(lpPathName: LPCSTR): WINBOOL{.stdcall,

     dynlib: "kernel32", importc: "SetCurrentDirectoryA".}

@@ -14267,7 +14267,7 @@ proc GetFileSecurityA*(lpFileName: LPCSTR,
 proc FindFirstChangeNotificationA*(lpPathName: LPCSTR, bWatchSubtree: WINBOOL,

                                    dwNotifyFilter: DWORD): HANDLE{.stdcall,

     dynlib: "kernel32", importc: "FindFirstChangeNotificationA".}

-proc IsBadStringPtrA*(lpsz: LPCSTR, ucchMax: UINT): WINBOOL{.stdcall,

+proc IsBadStringPtrA*(lpsz: LPCSTR, ucchMax: WINUINT): WINBOOL{.stdcall,

     dynlib: "kernel32", importc: "IsBadStringPtrA".}

 proc LookupAccountSidA*(lpSystemName: LPCSTR, Sid: PSID, Name: LPSTR,

                         cbName: LPDWORD, ReferencedDomainName: LPSTR,

@@ -14304,7 +14304,7 @@ proc SetComputerNameA*(lpComputerName: LPCSTR): WINBOOL{.stdcall,
     dynlib: "kernel32", importc: "SetComputerNameA".}

 proc GetUserNameA*(lpBuffer: LPSTR, nSize: LPDWORD): WINBOOL{.stdcall,

     dynlib: "advapi32", importc: "GetUserNameA".}

-proc LoadKeyboardLayoutA*(pwszKLID: LPCSTR, Flags: UINT): HKL{.stdcall,

+proc LoadKeyboardLayoutA*(pwszKLID: LPCSTR, Flags: WINUINT): HKL{.stdcall,

     dynlib: "user32", importc: "LoadKeyboardLayoutA".}

 proc GetKeyboardLayoutNameA*(pwszKLID: LPSTR): WINBOOL{.stdcall,

     dynlib: "user32", importc: "GetKeyboardLayoutNameA".}

@@ -14332,35 +14332,35 @@ proc GetUserObjectInformationA*(hObj: HANDLE, nIndex: int32, pvInfo: PVOID,
 proc SetUserObjectInformationA*(hObj: HANDLE, nIndex: int32, pvInfo: PVOID,

                                 nLength: DWORD): WINBOOL{.stdcall,

     dynlib: "user32", importc: "SetUserObjectInformationA".}

-proc RegisterWindowMessageA*(lpString: LPCSTR): UINT{.stdcall, dynlib: "user32",

+proc RegisterWindowMessageA*(lpString: LPCSTR): WINUINT{.stdcall, dynlib: "user32",

     importc: "RegisterWindowMessageA".}

-proc GetMessageA*(lpMsg: LPMSG, wnd: HWND, wMsgFilterMin: UINT,

-                  wMsgFilterMax: UINT): WINBOOL{.stdcall, dynlib: "user32",

+proc GetMessageA*(lpMsg: LPMSG, wnd: HWND, wMsgFilterMin: WINUINT,

+                  wMsgFilterMax: WINUINT): WINBOOL{.stdcall, dynlib: "user32",

     importc: "GetMessageA".}

 proc DispatchMessageA*(lpMsg: LPMSG): LONG{.stdcall, dynlib: "user32",

     importc: "DispatchMessageA".}

-proc PeekMessageA*(lpMsg: LPMSG, wnd: HWND, wMsgFilterMin: UINT,

-                   wMsgFilterMax: UINT, wRemoveMsg: UINT): WINBOOL{.stdcall,

+proc PeekMessageA*(lpMsg: LPMSG, wnd: HWND, wMsgFilterMin: WINUINT,

+                   wMsgFilterMax: WINUINT, wRemoveMsg: WINUINT): WINBOOL{.stdcall,

     dynlib: "user32", importc: "PeekMessageA".}

-proc SendMessageA*(wnd: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM): LRESULT{.

+proc SendMessageA*(wnd: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM): LRESULT{.

     stdcall, dynlib: "user32", importc: "SendMessageA".}

-proc SendMessageTimeoutA*(wnd: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM,

-                          fuFlags: UINT, uTimeout: UINT, lpdwResult: LPDWORD): LRESULT{.

+proc SendMessageTimeoutA*(wnd: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM,

+                          fuFlags: WINUINT, uTimeout: WINUINT, lpdwResult: LPDWORD): LRESULT{.

     stdcall, dynlib: "user32", importc: "SendMessageTimeoutA".}

-proc SendNotifyMessageA*(wnd: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM): WINBOOL{.

+proc SendNotifyMessageA*(wnd: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM): WINBOOL{.

     stdcall, dynlib: "user32", importc: "SendNotifyMessageA".}

-proc SendMessageCallbackA*(wnd: HWND, Msg: UINT, wp: WPARAM,

+proc SendMessageCallbackA*(wnd: HWND, Msg: WINUINT, wp: WPARAM,

                            lp: LPARAM, lpResultCallBack: SENDASYNCPROC,

                            dwData: DWORD): WINBOOL{.stdcall, dynlib: "user32",

     importc: "SendMessageCallbackA".}

-proc PostMessageA*(wnd: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM): WINBOOL{.

+proc PostMessageA*(wnd: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM): WINBOOL{.

     stdcall, dynlib: "user32", importc: "PostMessageA".}

-proc PostThreadMessageA*(idThread: DWORD, Msg: UINT, wp: WPARAM,

+proc PostThreadMessageA*(idThread: DWORD, Msg: WINUINT, wp: WPARAM,

                          lp: LPARAM): WINBOOL{.stdcall, dynlib: "user32",

     importc: "PostThreadMessageA".}

-proc DefWindowProcA*(wnd: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM): LRESULT{.

+proc DefWindowProcA*(wnd: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM): LRESULT{.

     stdcall, dynlib: "user32", importc: "DefWindowProcA".}

-proc CallWindowProcA*(lpPrevWndFunc: WNDPROC, wnd: HWND, Msg: UINT,

+proc CallWindowProcA*(lpPrevWndFunc: WNDPROC, wnd: HWND, Msg: WINUINT,

                       wp: WPARAM, lp: LPARAM): LRESULT{.stdcall,

     dynlib: "user32", importc: "CallWindowProcA".}

 proc RegisterClassA*(lpWndClass: LPWNDCLASS): ATOM{.stdcall, dynlib: "user32",

@@ -14398,18 +14398,18 @@ proc DialogBoxIndirectParamA*(hInstance: HINST, hDialogTemplate: LPCDLGTEMPLATE,
 proc SetDlgItemTextA*(hDlg: HWND, nIDDlgItem: int32, lpString: LPCSTR): WINBOOL{.

     stdcall, dynlib: "user32", importc: "SetDlgItemTextA".}

 proc GetDlgItemTextA*(hDlg: HWND, nIDDlgItem: int32, lpString: LPSTR,

-                      nMaxCount: int32): UINT{.stdcall, dynlib: "user32",

+                      nMaxCount: int32): WINUINT{.stdcall, dynlib: "user32",

     importc: "GetDlgItemTextA".}

-proc SendDlgItemMessageA*(hDlg: HWND, nIDDlgItem: int32, Msg: UINT,

+proc SendDlgItemMessageA*(hDlg: HWND, nIDDlgItem: int32, Msg: WINUINT,

                           wp: WPARAM, lp: LPARAM): LONG{.stdcall,

     dynlib: "user32", importc: "SendDlgItemMessageA".}

-proc DefDlgProcA*(hDlg: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM): LRESULT{.

+proc DefDlgProcA*(hDlg: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM): LRESULT{.

     stdcall, dynlib: "user32", importc: "DefDlgProcA".}

 proc CallMsgFilterA*(lpMsg: LPMSG, nCode: int32): WINBOOL{.stdcall,

     dynlib: "user32", importc: "CallMsgFilterA".}

-proc RegisterClipboardFormatA*(lpszFormat: LPCSTR): UINT{.stdcall,

+proc RegisterClipboardFormatA*(lpszFormat: LPCSTR): WINUINT{.stdcall,

     dynlib: "user32", importc: "RegisterClipboardFormatA".}

-proc GetClipboardFormatNameA*(format: UINT, lpszFormatName: LPSTR,

+proc GetClipboardFormatNameA*(format: WINUINT, lpszFormatName: LPSTR,

                               cchMaxCount: int32): int32{.stdcall,

     dynlib: "user32", importc: "GetClipboardFormatNameA".}

 proc CharToOemA*(lpszSrc: LPCSTR, lpszDst: LPSTR): WINBOOL{.stdcall,

@@ -14446,9 +14446,9 @@ proc VkKeyScanA*(ch: CHAR): SHORT{.stdcall, dynlib: "user32",
                                    importc: "VkKeyScanA".}

 proc VkKeyScanExA*(ch: CHAR, dwhkl: HKL): SHORT{.stdcall, dynlib: "user32",

     importc: "VkKeyScanExA".}

-proc MapVirtualKeyA*(uCode: UINT, uMapType: UINT): UINT{.stdcall,

+proc MapVirtualKeyA*(uCode: WINUINT, uMapType: WINUINT): WINUINT{.stdcall,

     dynlib: "user32", importc: "MapVirtualKeyA".}

-proc MapVirtualKeyExA*(uCode: UINT, uMapType: UINT, dwhkl: HKL): UINT{.stdcall,

+proc MapVirtualKeyExA*(uCode: WINUINT, uMapType: WINUINT, dwhkl: HKL): WINUINT{.stdcall,

     dynlib: "user32", importc: "MapVirtualKeyExA".}

 proc LoadAcceleratorsA*(hInstance: HINST, lpTableName: LPCSTR): HACCEL{.stdcall,

     dynlib: "user32", importc: "LoadAcceleratorsA".}

@@ -14463,35 +14463,35 @@ proc LoadMenuA*(hInstance: HINST, lpMenuName: LPCSTR): HMENU{.stdcall,
     dynlib: "user32", importc: "LoadMenuA".}

 proc LoadMenuIndirectA*(lpMenuTemplate: LPMENUTEMPLATE): HMENU{.stdcall,

     dynlib: "user32", importc: "LoadMenuIndirectA".}

-proc ChangeMenuA*(menu: HMENU, cmd: UINT, lpszNewItem: LPCSTR, cmdInsert: UINT,

-                  flags: UINT): WINBOOL{.stdcall, dynlib: "user32",

+proc ChangeMenuA*(menu: HMENU, cmd: WINUINT, lpszNewItem: LPCSTR, cmdInsert: WINUINT,

+                  flags: WINUINT): WINBOOL{.stdcall, dynlib: "user32",

     importc: "ChangeMenuA".}

-proc GetMenuStringA*(menu: HMENU, uIDItem: UINT, lpString: LPSTR,

-                     nMaxCount: int32, uFlag: UINT): int32{.stdcall,

+proc GetMenuStringA*(menu: HMENU, uIDItem: WINUINT, lpString: LPSTR,

+                     nMaxCount: int32, uFlag: WINUINT): int32{.stdcall,

     dynlib: "user32", importc: "GetMenuStringA".}

-proc InsertMenuA*(menu: HMENU, uPosition: UINT, uFlags: UINT, uIDNewItem: UINT,

+proc InsertMenuA*(menu: HMENU, uPosition: WINUINT, uFlags: WINUINT, uIDNewItem: WINUINT,

                   lpNewItem: LPCSTR): WINBOOL{.stdcall, dynlib: "user32",

     importc: "InsertMenuA".}

-proc AppendMenuA*(menu: HMENU, uFlags: UINT, uIDNewItem: UINT,

+proc AppendMenuA*(menu: HMENU, uFlags: WINUINT, uIDNewItem: WINUINT,

                   lpNewItem: LPCSTR): WINBOOL{.stdcall, dynlib: "user32",

     importc: "AppendMenuA".}

-proc ModifyMenuA*(hMnu: HMENU, uPosition: UINT, uFlags: UINT, uIDNewItem: UINT,

+proc ModifyMenuA*(hMnu: HMENU, uPosition: WINUINT, uFlags: WINUINT, uIDNewItem: WINUINT,

                   lpNewItem: LPCSTR): WINBOOL{.stdcall, dynlib: "user32",

     importc: "ModifyMenuA".}

-proc InsertMenuItemA*(para1: HMENU, para2: UINT, para3: WINBOOL,

+proc InsertMenuItemA*(para1: HMENU, para2: WINUINT, para3: WINBOOL,

                       para4: LPCMENUITEMINFO): WINBOOL{.stdcall,

     dynlib: "user32", importc: "InsertMenuItemA".}

-proc GetMenuItemInfoA*(para1: HMENU, para2: UINT, para3: WINBOOL,

+proc GetMenuItemInfoA*(para1: HMENU, para2: WINUINT, para3: WINBOOL,

                        para4: LPMENUITEMINFO): WINBOOL{.stdcall,

     dynlib: "user32", importc: "GetMenuItemInfoA".}

-proc SetMenuItemInfoA*(para1: HMENU, para2: UINT, para3: WINBOOL,

+proc SetMenuItemInfoA*(para1: HMENU, para2: WINUINT, para3: WINBOOL,

                        para4: LPCMENUITEMINFO): WINBOOL{.stdcall,

     dynlib: "user32", importc: "SetMenuItemInfoA".}

 proc DrawTextA*(hDC: HDC, lpString: LPCSTR, nCount: int32, lpRect: LPRECT,

-                uFormat: UINT): int32{.stdcall, dynlib: "user32",

+                uFormat: WINUINT): int32{.stdcall, dynlib: "user32",

                                        importc: "DrawTextA".}

 proc DrawTextExA*(para1: HDC, para2: LPSTR, para3: int32, para4: LPRECT,

-                  para5: UINT, para6: LPDRAWTEXTPARAMS): int32{.stdcall,

+                  para5: WINUINT, para6: LPDRAWTEXTPARAMS): int32{.stdcall,

     dynlib: "user32", importc: "DrawTextExA".}

 proc GrayStringA*(hDC: HDC, hBrush: HBRUSH, lpOutputFunc: GRAYSTRINGPROC,

                   lpData: LPARAM, nCount: int32, X: int32, Y: int32,

@@ -14499,7 +14499,7 @@ proc GrayStringA*(hDC: HDC, hBrush: HBRUSH, lpOutputFunc: GRAYSTRINGPROC,
     dynlib: "user32", importc: "GrayStringA".}

 proc DrawStateA*(para1: HDC, para2: HBRUSH, para3: DRAWSTATEPROC, para4: LPARAM,

                  para5: WPARAM, para6: int32, para7: int32, para8: int32,

-                 para9: int32, para10: UINT): WINBOOL{.stdcall,

+                 para9: int32, para10: WINUINT): WINBOOL{.stdcall,

     dynlib: "user32", importc: "DrawStateA".}

 proc TabbedTextOutA*(hDC: HDC, X: int32, Y: int32, lpString: LPCSTR,

                      nCount: int32, nTabPositions: int32,

@@ -14526,7 +14526,7 @@ proc GetWindowTextLengthA*(wnd: HWND): int32{.stdcall, dynlib: "user32",
     importc: "GetWindowTextLengthA".}

 proc MessageBoxA*(wnd: HWND, lpText: LPCSTR, lpCaption: LPCSTR, uType: int): int32{.

     stdcall, dynlib: "user32", importc: "MessageBoxA".}

-proc MessageBoxExA*(wnd: HWND, lpText: LPCSTR, lpCaption: LPCSTR, uType: UINT,

+proc MessageBoxExA*(wnd: HWND, lpText: LPCSTR, lpCaption: LPCSTR, uType: WINUINT,

                     wLanguageId: int16): int32{.stdcall, dynlib: "user32",

     importc: "MessageBoxExA".}

 proc MessageBoxIndirectA*(para1: LPMSGBOXPARAMS): int32{.stdcall,

@@ -14574,44 +14574,44 @@ proc LoadCursorFromFileA*(lpFileName: LPCSTR): HCURSOR{.stdcall,
     dynlib: "user32", importc: "LoadCursorFromFileA".}

 proc LoadIconA*(hInstance: HINST, lpIconName: LPCSTR): HICON{.stdcall,

     dynlib: "user32", importc: "LoadIconA".}

-proc LoadImageA*(para1: HINST, para2: LPCSTR, para3: UINT, para4: int32,

-                 para5: int32, para6: UINT): HANDLE{.stdcall, dynlib: "user32",

+proc LoadImageA*(para1: HINST, para2: LPCSTR, para3: WINUINT, para4: int32,

+                 para5: int32, para6: WINUINT): HANDLE{.stdcall, dynlib: "user32",

     importc: "LoadImageA".}

-proc LoadStringA*(hInstance: HINST, uID: UINT, lpBuffer: LPSTR,

+proc LoadStringA*(hInstance: HINST, uID: WINUINT, lpBuffer: LPSTR,

                   nBufferMax: int32): int32{.stdcall, dynlib: "user32",

     importc: "LoadStringA".}

 proc IsDialogMessageA*(hDlg: HWND, lpMsg: LPMSG): WINBOOL{.stdcall,

     dynlib: "user32", importc: "IsDialogMessageA".}

 proc DlgDirListA*(hDlg: HWND, lpPathSpec: LPSTR, nIDListBox: int32,

-                  nIDStaticPath: int32, uFileType: UINT): int32{.stdcall,

+                  nIDStaticPath: int32, uFileType: WINUINT): int32{.stdcall,

     dynlib: "user32", importc: "DlgDirListA".}

 proc DlgDirSelectExA*(hDlg: HWND, lpString: LPSTR, nCount: int32,

                       nIDListBox: int32): WINBOOL{.stdcall, dynlib: "user32",

     importc: "DlgDirSelectExA".}

 proc DlgDirListComboBoxA*(hDlg: HWND, lpPathSpec: LPSTR, nIDComboBox: int32,

-                          nIDStaticPath: int32, uFiletype: UINT): int32{.

+                          nIDStaticPath: int32, uFiletype: WINUINT): int32{.

     stdcall, dynlib: "user32", importc: "DlgDirListComboBoxA".}

 proc DlgDirSelectComboBoxExA*(hDlg: HWND, lpString: LPSTR, nCount: int32,

                               nIDComboBox: int32): WINBOOL{.stdcall,

     dynlib: "user32", importc: "DlgDirSelectComboBoxExA".}

-proc DefFrameProcA*(wnd: HWND, hWndMDIClient: HWND, uMsg: UINT, wp: WPARAM,

+proc DefFrameProcA*(wnd: HWND, hWndMDIClient: HWND, uMsg: WINUINT, wp: WPARAM,

                     lp: LPARAM): LRESULT{.stdcall, dynlib: "user32",

     importc: "DefFrameProcA".}

-proc DefMDIChildProcA*(wnd: HWND, uMsg: UINT, wp: WPARAM, lp: LPARAM): LRESULT{.

+proc DefMDIChildProcA*(wnd: HWND, uMsg: WINUINT, wp: WPARAM, lp: LPARAM): LRESULT{.

     stdcall, dynlib: "user32", importc: "DefMDIChildProcA".}

 proc CreateMDIWindowA*(lpClassName: LPSTR, lpWindowName: LPSTR, dwStyle: DWORD,

                        X: int32, Y: int32, nWidth: int32, nHeight: int32,

                        hWndParent: HWND, hInstance: HINST, lp: LPARAM): HWND{.

     stdcall, dynlib: "user32", importc: "CreateMDIWindowA".}

-proc WinHelpA*(hWndMain: HWND, lpszHelp: LPCSTR, uCommand: UINT, dwData: DWORD): WINBOOL{.

+proc WinHelpA*(hWndMain: HWND, lpszHelp: LPCSTR, uCommand: WINUINT, dwData: DWORD): WINBOOL{.

     stdcall, dynlib: "user32", importc: "WinHelpA".}

 proc ChangeDisplaySettingsA*(lpDevMode: LPDEVMODE, dwFlags: DWORD): LONG{.

     stdcall, dynlib: "user32", importc: "ChangeDisplaySettingsA".}

 proc EnumDisplaySettingsA*(lpszDeviceName: LPCSTR, iModeNum: DWORD,

                            lpDevMode: LPDEVMODE): WINBOOL{.stdcall,

     dynlib: "user32", importc: "EnumDisplaySettingsA".}

-proc SystemParametersInfoA*(uiAction: UINT, uiParam: UINT, pvParam: PVOID,

-                            fWinIni: UINT): WINBOOL{.stdcall, dynlib: "user32",

+proc SystemParametersInfoA*(uiAction: WINUINT, uiParam: WINUINT, pvParam: PVOID,

+                            fWinIni: WINUINT): WINBOOL{.stdcall, dynlib: "user32",

     importc: "SystemParametersInfoA".}

 proc AddFontResourceA*(para1: LPCSTR): int32{.stdcall, dynlib: "gdi32",

     importc: "AddFontResourceA".}

@@ -14643,24 +14643,24 @@ proc EnumFontsA*(para1: HDC, para2: LPCSTR, para3: ENUMFONTSPROC, para4: LPARAM)
     stdcall, dynlib: "gdi32", importc: "EnumFontsA".}

 proc EnumFontsA*(para1: HDC, para2: LPCSTR, para3: ENUMFONTSPROC, para4: pointer): int32{.

     stdcall, dynlib: "gdi32", importc: "EnumFontsA".}

-proc GetCharWidthA*(para1: HDC, para2: UINT, para3: UINT, para4: LPINT): WINBOOL{.

+proc GetCharWidthA*(para1: HDC, para2: WINUINT, para3: WINUINT, para4: LPINT): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "GetCharWidthA".}

-proc GetCharWidth32A*(para1: HDC, para2: UINT, para3: UINT, para4: LPINT): WINBOOL{.

+proc GetCharWidth32A*(para1: HDC, para2: WINUINT, para3: WINUINT, para4: LPINT): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "GetCharWidth32A".}

-proc GetCharWidthFloatA*(para1: HDC, para2: UINT, para3: UINT, para4: ptr float32): WINBOOL{.

+proc GetCharWidthFloatA*(para1: HDC, para2: WINUINT, para3: WINUINT, para4: ptr float32): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "GetCharWidthFloatA".}

-proc GetCharABCWidthsA*(para1: HDC, para2: UINT, para3: UINT, para4: LPABC): WINBOOL{.

+proc GetCharABCWidthsA*(para1: HDC, para2: WINUINT, para3: WINUINT, para4: LPABC): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "GetCharABCWidthsA".}

-proc GetCharABCWidthsFloatA*(para1: HDC, para2: UINT, para3: UINT,

+proc GetCharABCWidthsFloatA*(para1: HDC, para2: WINUINT, para3: WINUINT,

                              para4: LPABCFLOAT): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "GetCharABCWidthsFloatA".}

-proc GetGlyphOutlineA*(para1: HDC, para2: UINT, para3: UINT,

+proc GetGlyphOutlineA*(para1: HDC, para2: WINUINT, para3: WINUINT,

                        para4: LPGLYPHMETRICS, para5: DWORD, para6: LPVOID,

                        para7: PMAT2): DWORD{.stdcall, dynlib: "gdi32",

     importc: "GetGlyphOutlineA".}

 proc GetMetaFileA*(para1: LPCSTR): HMETAFILE{.stdcall, dynlib: "gdi32",

     importc: "GetMetaFileA".}

-proc GetOutlineTextMetricsA*(para1: HDC, para2: UINT, para3: LPOUTLINETEXTMETRIC): UINT{.

+proc GetOutlineTextMetricsA*(para1: HDC, para2: WINUINT, para3: LPOUTLINETEXTMETRIC): WINUINT{.

     stdcall, dynlib: "gdi32", importc: "GetOutlineTextMetricsA".}

 proc GetTextExtentPointA*(para1: HDC, para2: LPCSTR, para3: int32, para4: LPSIZE): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "GetTextExtentPointA".}

@@ -14684,7 +14684,7 @@ proc CreateEnhMetaFileA*(para1: HDC, para2: LPCSTR, para3: LPRECT, para4: LPCSTR
     stdcall, dynlib: "gdi32", importc: "CreateEnhMetaFileA".}

 proc GetEnhMetaFileA*(para1: LPCSTR): HENHMETAFILE{.stdcall, dynlib: "gdi32",

     importc: "GetEnhMetaFileA".}

-proc GetEnhMetaFileDescriptionA*(para1: HENHMETAFILE, para2: UINT, para3: LPSTR): UINT{.

+proc GetEnhMetaFileDescriptionA*(para1: HENHMETAFILE, para2: WINUINT, para3: LPSTR): WINUINT{.

     stdcall, dynlib: "gdi32", importc: "GetEnhMetaFileDescriptionA".}

 proc GetTextMetricsA*(para1: HDC, para2: LPTEXTMETRIC): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "GetTextMetricsA".}

@@ -14695,8 +14695,8 @@ proc GetObjectA*(para1: HGDIOBJ, para2: int32, para3: LPVOID): int32{.stdcall,
 proc TextOutA*(para1: HDC, para2: int32, para3: int32, para4: LPCSTR,

                para5: int32): WINBOOL{.stdcall, dynlib: "gdi32",

                                        importc: "TextOutA".}

-proc ExtTextOutA*(para1: HDC, para2: int32, para3: int32, para4: UINT,

-                  para5: LPRECT, para6: LPCSTR, para7: UINT, para8: LPINT): WINBOOL{.

+proc ExtTextOutA*(para1: HDC, para2: int32, para3: int32, para4: WINUINT,

+                  para5: LPRECT, para6: LPCSTR, para7: WINUINT, para8: LPINT): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "ExtTextOutA".}

 proc PolyTextOutA*(para1: HDC, para2: PPOLYTEXT, para3: int32): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "PolyTextOutA".}

@@ -14712,19 +14712,19 @@ proc GetICMProfileA*(para1: HDC, para2: DWORD, para3: LPSTR): WINBOOL{.stdcall,
     dynlib: "gdi32", importc: "GetICMProfileA".}

 proc SetICMProfileA*(para1: HDC, para2: LPSTR): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "SetICMProfileA".}

-proc UpdateICMRegKeyA*(para1: DWORD, para2: DWORD, para3: LPSTR, para4: UINT): WINBOOL{.

+proc UpdateICMRegKeyA*(para1: DWORD, para2: DWORD, para3: LPSTR, para4: WINUINT): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "UpdateICMRegKeyA".}

 proc EnumICMProfilesA*(para1: HDC, para2: ICMENUMPROC, para3: LPARAM): int32{.

     stdcall, dynlib: "gdi32", importc: "EnumICMProfilesA".}

 proc PropertySheetA*(lppsph: LPCPROPSHEETHEADER): int32{.stdcall,

     dynlib: "comctl32", importc: "PropertySheetA".}

 proc ImageList_LoadImageA*(hi: HINST, lpbmp: LPCSTR, cx: int32, cGrow: int32,

-                           crMask: COLORREF, uType: UINT, uFlags: UINT): HIMAGELIST{.

+                           crMask: COLORREF, uType: WINUINT, uFlags: WINUINT): HIMAGELIST{.

     stdcall, dynlib: "comctl32", importc: "ImageList_LoadImageA".}

 proc CreateStatusWindowA*(style: LONG, lpszText: LPCSTR, hwndParent: HWND,

-                          wID: UINT): HWND{.stdcall, dynlib: "comctl32",

+                          wID: WINUINT): HWND{.stdcall, dynlib: "comctl32",

     importc: "CreateStatusWindowA".}

-proc DrawStatusTextA*(hDC: HDC, lprc: LPRECT, pszText: LPCSTR, uFlags: UINT){.

+proc DrawStatusTextA*(hDC: HDC, lprc: LPRECT, pszText: LPCSTR, uFlags: WINUINT){.

     stdcall, dynlib: "comctl32", importc: "DrawStatusTextA".}

 proc GetOpenFileNameA*(para1: LPOPENFILENAME): WINBOOL{.stdcall,

     dynlib: "comdlg32", importc: "GetOpenFileNameA".}

@@ -15077,7 +15077,7 @@ proc Shell_NotifyIconA*(dwMessage: DWORD, lpData: PNotifyIconDataA): WINBOOL{.
 proc DdeCreateStringHandleA*(para1: DWORD, para2: cstring, para3: int32): HSZ{.

     stdcall, dynlib: "user32", importc: "DdeCreateStringHandleA".}

 proc DdeInitializeA*(para1: LPDWORD, para2: PFNCALLBACK, para3: DWORD,

-                     para4: DWORD): UINT{.stdcall, dynlib: "user32",

+                     para4: DWORD): WINUINT{.stdcall, dynlib: "user32",

     importc: "DdeInitializeA".}

 proc DdeQueryStringA*(para1: DWORD, para2: HSZ, para3: cstring, para4: DWORD,

                       para5: int32): DWORD{.stdcall, dynlib: "user32",

@@ -15157,7 +15157,7 @@ proc GetModuleFileNameW*(hModule: HINST, lpFilename: LPWSTR, nSize: DWORD): DWOR
     stdcall, dynlib: "kernel32", importc: "GetModuleFileNameW".}

 proc GetModuleHandleW*(lpModuleName: LPCWSTR): HMODULE{.stdcall,

     dynlib: "kernel32", importc: "GetModuleHandleW".}

-proc FatalAppExitW*(uAction: UINT, lpMessageText: LPCWSTR){.stdcall,

+proc FatalAppExitW*(uAction: WINUINT, lpMessageText: LPCWSTR){.stdcall,

     dynlib: "kernel32", importc: "FatalAppExitW".}

 proc GetCommandLineW*(): LPWSTR{.stdcall, dynlib: "kernel32",

                                  importc: "GetCommandLineW".}

@@ -15194,15 +15194,15 @@ proc GlobalAddAtomW*(lpString: LPCWSTR): ATOM{.stdcall, dynlib: "kernel32",
     importc: "GlobalAddAtomW".}

 proc GlobalFindAtomW*(lpString: LPCWSTR): ATOM{.stdcall, dynlib: "kernel32",

     importc: "GlobalFindAtomW".}

-proc GlobalGetAtomNameW*(nAtom: ATOM, lpBuffer: LPWSTR, nSize: int32): UINT{.

+proc GlobalGetAtomNameW*(nAtom: ATOM, lpBuffer: LPWSTR, nSize: int32): WINUINT{.

     stdcall, dynlib: "kernel32", importc: "GlobalGetAtomNameW".}

 proc AddAtomW*(lpString: LPCWSTR): ATOM{.stdcall, dynlib: "kernel32",

     importc: "AddAtomW".}

 proc FindAtomW*(lpString: LPCWSTR): ATOM{.stdcall, dynlib: "kernel32",

     importc: "FindAtomW".}

-proc GetAtomNameW*(nAtom: ATOM, lpBuffer: LPWSTR, nSize: int32): UINT{.stdcall,

+proc GetAtomNameW*(nAtom: ATOM, lpBuffer: LPWSTR, nSize: int32): WINUINT{.stdcall,

     dynlib: "kernel32", importc: "GetAtomNameW".}

-proc GetProfileIntW*(lpAppName: LPCWSTR, lpKeyName: LPCWSTR, nDefault: WINT): UINT{.

+proc GetProfileIntW*(lpAppName: LPCWSTR, lpKeyName: LPCWSTR, nDefault: WINT): WINUINT{.

     stdcall, dynlib: "kernel32", importc: "GetProfileIntW".}

 proc GetProfileStringW*(lpAppName: LPCWSTR, lpKeyName: LPCWSTR,

                         lpDefault: LPCWSTR, lpReturnedString: LPWSTR,

@@ -15217,7 +15217,7 @@ proc GetProfileSectionW*(lpAppName: LPCWSTR, lpReturnedString: LPWSTR,
 proc WriteProfileSectionW*(lpAppName: LPCWSTR, lpString: LPCWSTR): WINBOOL{.

     stdcall, dynlib: "kernel32", importc: "WriteProfileSectionW".}

 proc GetPrivateProfileIntW*(lpAppName: LPCWSTR, lpKeyName: LPCWSTR,

-                            nDefault: WINT, lpFileName: LPCWSTR): UINT{.stdcall,

+                            nDefault: WINT, lpFileName: LPCWSTR): WINUINT{.stdcall,

     dynlib: "kernel32", importc: "GetPrivateProfileIntW".}

 proc GetPrivateProfileStringW*(lpAppName: LPCWSTR, lpKeyName: LPCWSTR,

                                lpDefault: LPCWSTR, lpReturnedString: LPWSTR,

@@ -15232,16 +15232,16 @@ proc GetPrivateProfileSectionW*(lpAppName: LPCWSTR, lpReturnedString: LPWSTR,
 proc WritePrivateProfileSectionW*(lpAppName: LPCWSTR, lpString: LPCWSTR,

                                   lpFileName: LPCWSTR): WINBOOL{.stdcall,

     dynlib: "kernel32", importc: "WritePrivateProfileSectionW".}

-proc GetDriveTypeW*(lpRootPathName: LPCWSTR): UINT{.stdcall, dynlib: "kernel32",

+proc GetDriveTypeW*(lpRootPathName: LPCWSTR): WINUINT{.stdcall, dynlib: "kernel32",

     importc: "GetDriveTypeW".}

-proc GetSystemDirectoryW*(lpBuffer: LPWSTR, uSize: UINT): UINT{.stdcall,

+proc GetSystemDirectoryW*(lpBuffer: LPWSTR, uSize: WINUINT): WINUINT{.stdcall,

     dynlib: "kernel32", importc: "GetSystemDirectoryW".}

 proc GetTempPathW*(nBufferLength: DWORD, lpBuffer: LPWSTR): DWORD{.stdcall,

     dynlib: "kernel32", importc: "GetTempPathW".}

 proc GetTempFileNameW*(lpPathName: LPCWSTR, lpPrefixString: LPCWSTR,

-                       uUnique: UINT, lpTempFileName: LPWSTR): UINT{.stdcall,

+                       uUnique: WINUINT, lpTempFileName: LPWSTR): WINUINT{.stdcall,

     dynlib: "kernel32", importc: "GetTempFileNameW".}

-proc GetWindowsDirectoryW*(lpBuffer: LPWSTR, uSize: UINT): UINT{.stdcall,

+proc GetWindowsDirectoryW*(lpBuffer: LPWSTR, uSize: WINUINT): WINUINT{.stdcall,

     dynlib: "kernel32", importc: "GetWindowsDirectoryW".}

 proc SetCurrentDirectoryW*(lpPathName: LPCWSTR): WINBOOL{.stdcall,

     dynlib: "kernel32", importc: "SetCurrentDirectoryW".}

@@ -15382,7 +15382,7 @@ proc GetFileSecurityW*(lpFileName: LPCWSTR,
 proc FindFirstChangeNotificationW*(lpPathName: LPCWSTR, bWatchSubtree: WINBOOL,

                                    dwNotifyFilter: DWORD): HANDLE{.stdcall,

     dynlib: "kernel32", importc: "FindFirstChangeNotificationW".}

-proc IsBadStringPtrW*(lpsz: LPCWSTR, ucchMax: UINT): WINBOOL{.stdcall,

+proc IsBadStringPtrW*(lpsz: LPCWSTR, ucchMax: WINUINT): WINBOOL{.stdcall,

     dynlib: "kernel32", importc: "IsBadStringPtrW".}

 proc LookupAccountSidW*(lpSystemName: LPCWSTR, Sid: PSID, Name: LPWSTR,

                         cbName: LPDWORD, ReferencedDomainName: LPWSTR,

@@ -15421,7 +15421,7 @@ proc SetComputerNameW*(lpComputerName: LPCWSTR): WINBOOL{.stdcall,
     dynlib: "kernel32", importc: "SetComputerNameW".}

 proc GetUserNameW*(lpBuffer: LPWSTR, nSize: LPDWORD): WINBOOL{.stdcall,

     dynlib: "advapi32", importc: "GetUserNameW".}

-proc LoadKeyboardLayoutW*(pwszKLID: LPCWSTR, Flags: UINT): HKL{.stdcall,

+proc LoadKeyboardLayoutW*(pwszKLID: LPCWSTR, Flags: WINUINT): HKL{.stdcall,

     dynlib: "user32", importc: "LoadKeyboardLayoutW".}

 proc GetKeyboardLayoutNameW*(pwszKLID: LPWSTR): WINBOOL{.stdcall,

     dynlib: "user32", importc: "GetKeyboardLayoutNameW".}

@@ -15449,35 +15449,35 @@ proc GetUserObjectInformationW*(hObj: HANDLE, nIndex: int32, pvInfo: PVOID,
 proc SetUserObjectInformationW*(hObj: HANDLE, nIndex: int32, pvInfo: PVOID,

                                 nLength: DWORD): WINBOOL{.stdcall,

     dynlib: "user32", importc: "SetUserObjectInformationW".}

-proc RegisterWindowMessageW*(lpString: LPCWSTR): UINT{.stdcall,

+proc RegisterWindowMessageW*(lpString: LPCWSTR): WINUINT{.stdcall,

     dynlib: "user32", importc: "RegisterWindowMessageW".}

-proc GetMessageW*(lpMsg: LPMSG, wnd: HWND, wMsgFilterMin: UINT,

-                  wMsgFilterMax: UINT): WINBOOL{.stdcall, dynlib: "user32",

+proc GetMessageW*(lpMsg: LPMSG, wnd: HWND, wMsgFilterMin: WINUINT,

+                  wMsgFilterMax: WINUINT): WINBOOL{.stdcall, dynlib: "user32",

     importc: "GetMessageW".}

 proc DispatchMessageW*(lpMsg: LPMSG): LONG{.stdcall, dynlib: "user32",

     importc: "DispatchMessageW".}

-proc PeekMessageW*(lpMsg: LPMSG, wnd: HWND, wMsgFilterMin: UINT,

-                   wMsgFilterMax: UINT, wRemoveMsg: UINT): WINBOOL{.stdcall,

+proc PeekMessageW*(lpMsg: LPMSG, wnd: HWND, wMsgFilterMin: WINUINT,

+                   wMsgFilterMax: WINUINT, wRemoveMsg: WINUINT): WINBOOL{.stdcall,

     dynlib: "user32", importc: "PeekMessageW".}

-proc SendMessageW*(wnd: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM): LRESULT{.

+proc SendMessageW*(wnd: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM): LRESULT{.

     stdcall, dynlib: "user32", importc: "SendMessageW".}

-proc SendMessageTimeoutW*(wnd: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM,

-                          fuFlags: UINT, uTimeout: UINT, lpdwResult: LPDWORD): LRESULT{.

+proc SendMessageTimeoutW*(wnd: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM,

+                          fuFlags: WINUINT, uTimeout: WINUINT, lpdwResult: LPDWORD): LRESULT{.

     stdcall, dynlib: "user32", importc: "SendMessageTimeoutW".}

-proc SendNotifyMessageW*(wnd: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM): WINBOOL{.

+proc SendNotifyMessageW*(wnd: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM): WINBOOL{.

     stdcall, dynlib: "user32", importc: "SendNotifyMessageW".}

-proc SendMessageCallbackW*(wnd: HWND, Msg: UINT, wp: WPARAM,

+proc SendMessageCallbackW*(wnd: HWND, Msg: WINUINT, wp: WPARAM,

                            lp: LPARAM, lpResultCallBack: SENDASYNCPROC,

                            dwData: DWORD): WINBOOL{.stdcall, dynlib: "user32",

     importc: "SendMessageCallbackW".}

-proc PostMessageW*(wnd: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM): WINBOOL{.

+proc PostMessageW*(wnd: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM): WINBOOL{.

     stdcall, dynlib: "user32", importc: "PostMessageW".}

-proc PostThreadMessageW*(idThread: DWORD, Msg: UINT, wp: WPARAM,

+proc PostThreadMessageW*(idThread: DWORD, Msg: WINUINT, wp: WPARAM,

                          lp: LPARAM): WINBOOL{.stdcall, dynlib: "user32",

     importc: "PostThreadMessageW".}

-proc DefWindowProcW*(wnd: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM): LRESULT{.

+proc DefWindowProcW*(wnd: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM): LRESULT{.

     stdcall, dynlib: "user32", importc: "DefWindowProcW".}

-proc CallWindowProcW*(lpPrevWndFunc: WNDPROC, wnd: HWND, Msg: UINT,

+proc CallWindowProcW*(lpPrevWndFunc: WNDPROC, wnd: HWND, Msg: WINUINT,

                       wp: WPARAM, lp: LPARAM): LRESULT{.stdcall,

     dynlib: "user32", importc: "CallWindowProcW".}

 proc RegisterClassW*(lpWndClass: LPWNDCLASSW): ATOM{.stdcall, dynlib: "user32",

@@ -15515,18 +15515,18 @@ proc DialogBoxIndirectParamW*(hInstance: HINST, hDialogTemplate: LPCDLGTEMPLATE,
 proc SetDlgItemTextW*(hDlg: HWND, nIDDlgItem: int32, lpString: LPCWSTR): WINBOOL{.

     stdcall, dynlib: "user32", importc: "SetDlgItemTextW".}

 proc GetDlgItemTextW*(hDlg: HWND, nIDDlgItem: int32, lpString: LPWSTR,

-                      nMaxCount: int32): UINT{.stdcall, dynlib: "user32",

+                      nMaxCount: int32): WINUINT{.stdcall, dynlib: "user32",

     importc: "GetDlgItemTextW".}

-proc SendDlgItemMessageW*(hDlg: HWND, nIDDlgItem: int32, Msg: UINT,

+proc SendDlgItemMessageW*(hDlg: HWND, nIDDlgItem: int32, Msg: WINUINT,

                           wp: WPARAM, lp: LPARAM): LONG{.stdcall,

     dynlib: "user32", importc: "SendDlgItemMessageW".}

-proc DefDlgProcW*(hDlg: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM): LRESULT{.

+proc DefDlgProcW*(hDlg: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM): LRESULT{.

     stdcall, dynlib: "user32", importc: "DefDlgProcW".}

 proc CallMsgFilterW*(lpMsg: LPMSG, nCode: int32): WINBOOL{.stdcall,

     dynlib: "user32", importc: "CallMsgFilterW".}

-proc RegisterClipboardFormatW*(lpszFormat: LPCWSTR): UINT{.stdcall,

+proc RegisterClipboardFormatW*(lpszFormat: LPCWSTR): WINUINT{.stdcall,

     dynlib: "user32", importc: "RegisterClipboardFormatW".}

-proc GetClipboardFormatNameW*(format: UINT, lpszFormatName: LPWSTR,

+proc GetClipboardFormatNameW*(format: WINUINT, lpszFormatName: LPWSTR,

                               cchMaxCount: int32): int32{.stdcall,

     dynlib: "user32", importc: "GetClipboardFormatNameW".}

 proc CharToOemW*(lpszSrc: LPCWSTR, lpszDst: LPSTR): WINBOOL{.stdcall,

@@ -15563,9 +15563,9 @@ proc VkKeyScanW*(ch: WCHAR): SHORT{.stdcall, dynlib: "user32",
                                     importc: "VkKeyScanW".}

 proc VkKeyScanExW*(ch: WCHAR, dwhkl: HKL): SHORT{.stdcall, dynlib: "user32",

     importc: "VkKeyScanExW".}

-proc MapVirtualKeyW*(uCode: UINT, uMapType: UINT): UINT{.stdcall,

+proc MapVirtualKeyW*(uCode: WINUINT, uMapType: WINUINT): WINUINT{.stdcall,

     dynlib: "user32", importc: "MapVirtualKeyW".}

-proc MapVirtualKeyExW*(uCode: UINT, uMapType: UINT, dwhkl: HKL): UINT{.stdcall,

+proc MapVirtualKeyExW*(uCode: WINUINT, uMapType: WINUINT, dwhkl: HKL): WINUINT{.stdcall,

     dynlib: "user32", importc: "MapVirtualKeyExW".}

 proc LoadAcceleratorsW*(hInstance: HINST, lpTableName: LPCWSTR): HACCEL{.

     stdcall, dynlib: "user32", importc: "LoadAcceleratorsW".}

@@ -15580,35 +15580,35 @@ proc LoadMenuW*(hInstance: HINST, lpMenuName: LPCWSTR): HMENU{.stdcall,
     dynlib: "user32", importc: "LoadMenuW".}

 proc LoadMenuIndirectW*(lpMenuTemplate: LPMENUTEMPLATE): HMENU{.stdcall,

     dynlib: "user32", importc: "LoadMenuIndirectW".}

-proc ChangeMenuW*(menu: HMENU, cmd: UINT, lpszNewItem: LPCWSTR,

-                  cmdInsert: UINT, flags: UINT): WINBOOL{.stdcall,

+proc ChangeMenuW*(menu: HMENU, cmd: WINUINT, lpszNewItem: LPCWSTR,

+                  cmdInsert: WINUINT, flags: WINUINT): WINBOOL{.stdcall,

     dynlib: "user32", importc: "ChangeMenuW".}

-proc GetMenuStringW*(menu: HMENU, uIDItem: UINT, lpString: LPWSTR,

-                     nMaxCount: int32, uFlag: UINT): int32{.stdcall,

+proc GetMenuStringW*(menu: HMENU, uIDItem: WINUINT, lpString: LPWSTR,

+                     nMaxCount: int32, uFlag: WINUINT): int32{.stdcall,

     dynlib: "user32", importc: "GetMenuStringW".}

-proc InsertMenuW*(menu: HMENU, uPosition: UINT, uFlags: UINT, uIDNewItem: UINT,

+proc InsertMenuW*(menu: HMENU, uPosition: WINUINT, uFlags: WINUINT, uIDNewItem: WINUINT,

                   lpNewItem: LPCWSTR): WINBOOL{.stdcall, dynlib: "user32",

     importc: "InsertMenuW".}

-proc AppendMenuW*(menu: HMENU, uFlags: UINT, uIDNewItem: UINT,

+proc AppendMenuW*(menu: HMENU, uFlags: WINUINT, uIDNewItem: WINUINT,

                   lpNewItem: LPCWSTR): WINBOOL{.stdcall, dynlib: "user32",

     importc: "AppendMenuW".}

-proc ModifyMenuW*(hMnu: HMENU, uPosition: UINT, uFlags: UINT, uIDNewItem: UINT,

+proc ModifyMenuW*(hMnu: HMENU, uPosition: WINUINT, uFlags: WINUINT, uIDNewItem: WINUINT,

                   lpNewItem: LPCWSTR): WINBOOL{.stdcall, dynlib: "user32",

     importc: "ModifyMenuW".}

-proc InsertMenuItemW*(para1: HMENU, para2: UINT, para3: WINBOOL,

+proc InsertMenuItemW*(para1: HMENU, para2: WINUINT, para3: WINBOOL,

                       para4: LPCMENUITEMINFO): WINBOOL{.stdcall,

     dynlib: "user32", importc: "InsertMenuItemW".}

-proc GetMenuItemInfoW*(para1: HMENU, para2: UINT, para3: WINBOOL,

+proc GetMenuItemInfoW*(para1: HMENU, para2: WINUINT, para3: WINBOOL,

                        para4: LPMENUITEMINFO): WINBOOL{.stdcall,

     dynlib: "user32", importc: "GetMenuItemInfoW".}

-proc SetMenuItemInfoW*(para1: HMENU, para2: UINT, para3: WINBOOL,

+proc SetMenuItemInfoW*(para1: HMENU, para2: WINUINT, para3: WINBOOL,

                        para4: LPCMENUITEMINFO): WINBOOL{.stdcall,

     dynlib: "user32", importc: "SetMenuItemInfoW".}

 proc DrawTextW*(hDC: HDC, lpString: LPCWSTR, nCount: int32, lpRect: LPRECT,

-                uFormat: UINT): int32{.stdcall, dynlib: "user32",

+                uFormat: WINUINT): int32{.stdcall, dynlib: "user32",

                                        importc: "DrawTextW".}

 proc DrawTextExW*(para1: HDC, para2: LPWSTR, para3: int32, para4: LPRECT,

-                  para5: UINT, para6: LPDRAWTEXTPARAMS): int32{.stdcall,

+                  para5: WINUINT, para6: LPDRAWTEXTPARAMS): int32{.stdcall,

     dynlib: "user32", importc: "DrawTextExW".}

 proc GrayStringW*(hDC: HDC, hBrush: HBRUSH, lpOutputFunc: GRAYSTRINGPROC,

                   lpData: LPARAM, nCount: int32, X: int32, Y: int32,

@@ -15616,7 +15616,7 @@ proc GrayStringW*(hDC: HDC, hBrush: HBRUSH, lpOutputFunc: GRAYSTRINGPROC,
     dynlib: "user32", importc: "GrayStringW".}

 proc DrawStateW*(para1: HDC, para2: HBRUSH, para3: DRAWSTATEPROC, para4: LPARAM,

                  para5: WPARAM, para6: int32, para7: int32, para8: int32,

-                 para9: int32, para10: UINT): WINBOOL{.stdcall,

+                 para9: int32, para10: WINUINT): WINBOOL{.stdcall,

     dynlib: "user32", importc: "DrawStateW".}

 proc TabbedTextOutW*(hDC: HDC, X: int32, Y: int32, lpString: LPCWSTR,

                      nCount: int32, nTabPositions: int32,

@@ -15641,10 +15641,10 @@ proc GetWindowTextW*(wnd: HWND, lpString: LPWSTR, nMaxCount: int32): int32{.
     stdcall, dynlib: "user32", importc: "GetWindowTextW".}

 proc GetWindowTextLengthW*(wnd: HWND): int32{.stdcall, dynlib: "user32",

     importc: "GetWindowTextLengthW".}

-proc MessageBoxW*(wnd: HWND, lpText: LPCWSTR, lpCaption: LPCWSTR, uType: UINT): int32{.

+proc MessageBoxW*(wnd: HWND, lpText: LPCWSTR, lpCaption: LPCWSTR, uType: WINUINT): int32{.

     stdcall, dynlib: "user32", importc: "MessageBoxW".}

 proc MessageBoxExW*(wnd: HWND, lpText: LPCWSTR, lpCaption: LPCWSTR,

-                    uType: UINT, wLanguageId: int16): int32{.stdcall,

+                    uType: WINUINT, wLanguageId: int16): int32{.stdcall,

     dynlib: "user32", importc: "MessageBoxExW".}

 proc MessageBoxIndirectW*(para1: LPMSGBOXPARAMS): int32{.stdcall,

     dynlib: "user32", importc: "MessageBoxIndirectW".}

@@ -15691,45 +15691,45 @@ proc LoadCursorFromFileW*(lpFileName: LPCWSTR): HCURSOR{.stdcall,
     dynlib: "user32", importc: "LoadCursorFromFileW".}

 proc LoadIconW*(hInstance: HINST, lpIconName: LPCWSTR): HICON{.stdcall,

     dynlib: "user32", importc: "LoadIconW".}

-proc LoadImageW*(para1: HINST, para2: LPCWSTR, para3: UINT, para4: int32,

-                 para5: int32, para6: UINT): HANDLE{.stdcall, dynlib: "user32",

+proc LoadImageW*(para1: HINST, para2: LPCWSTR, para3: WINUINT, para4: int32,

+                 para5: int32, para6: WINUINT): HANDLE{.stdcall, dynlib: "user32",

     importc: "LoadImageW".}

-proc LoadStringW*(hInstance: HINST, uID: UINT, lpBuffer: LPWSTR,

+proc LoadStringW*(hInstance: HINST, uID: WINUINT, lpBuffer: LPWSTR,

                   nBufferMax: int32): int32{.stdcall, dynlib: "user32",

     importc: "LoadStringW".}

 proc IsDialogMessageW*(hDlg: HWND, lpMsg: LPMSG): WINBOOL{.stdcall,

     dynlib: "user32", importc: "IsDialogMessageW".}

 proc DlgDirListW*(hDlg: HWND, lpPathSpec: LPWSTR, nIDListBox: int32,

-                  nIDStaticPath: int32, uFileType: UINT): int32{.stdcall,

+                  nIDStaticPath: int32, uFileType: WINUINT): int32{.stdcall,

     dynlib: "user32", importc: "DlgDirListW".}

 proc DlgDirSelectExW*(hDlg: HWND, lpString: LPWSTR, nCount: int32,

                       nIDListBox: int32): WINBOOL{.stdcall, dynlib: "user32",

     importc: "DlgDirSelectExW".}

 proc DlgDirListComboBoxW*(hDlg: HWND, lpPathSpec: LPWSTR, nIDComboBox: int32,

-                          nIDStaticPath: int32, uFiletype: UINT): int32{.

+                          nIDStaticPath: int32, uFiletype: WINUINT): int32{.

     stdcall, dynlib: "user32", importc: "DlgDirListComboBoxW".}

 proc DlgDirSelectComboBoxExW*(hDlg: HWND, lpString: LPWSTR, nCount: int32,

                               nIDComboBox: int32): WINBOOL{.stdcall,

     dynlib: "user32", importc: "DlgDirSelectComboBoxExW".}

-proc DefFrameProcW*(wnd: HWND, hWndMDIClient: HWND, uMsg: UINT, w: WPARAM,

+proc DefFrameProcW*(wnd: HWND, hWndMDIClient: HWND, uMsg: WINUINT, w: WPARAM,

                     lp: LPARAM): LRESULT{.stdcall, dynlib: "user32",

     importc: "DefFrameProcW".}

-proc DefMDIChildProcW*(wnd: HWND, uMsg: UINT, wp: WPARAM, lp: LPARAM): LRESULT{.

+proc DefMDIChildProcW*(wnd: HWND, uMsg: WINUINT, wp: WPARAM, lp: LPARAM): LRESULT{.

     stdcall, dynlib: "user32", importc: "DefMDIChildProcW".}

 proc CreateMDIWindowW*(lpClassName: LPWSTR, lpWindowName: LPWSTR,

                        dwStyle: DWORD, X: int32, Y: int32, nWidth: int32,

                        nHeight: int32, hWndParent: HWND, hInstance: HINST,

                        lp: LPARAM): HWND{.stdcall, dynlib: "user32",

     importc: "CreateMDIWindowW".}

-proc WinHelpW*(hWndMain: HWND, lpszHelp: LPCWSTR, uCommand: UINT, dwData: DWORD): WINBOOL{.

+proc WinHelpW*(hWndMain: HWND, lpszHelp: LPCWSTR, uCommand: WINUINT, dwData: DWORD): WINBOOL{.

     stdcall, dynlib: "user32", importc: "WinHelpW".}

 proc ChangeDisplaySettingsW*(lpDevMode: LPDEVMODEW, dwFlags: DWORD): LONG{.

     stdcall, dynlib: "user32", importc: "ChangeDisplaySettingsW".}

 proc EnumDisplaySettingsW*(lpszDeviceName: LPCWSTR, iModeNum: DWORD,

                            lpDevMode: LPDEVMODEW): WINBOOL{.stdcall,

     dynlib: "user32", importc: "EnumDisplaySettingsW".}

-proc SystemParametersInfoW*(uiAction: UINT, uiParam: UINT, pvParam: PVOID,

-                            fWinIni: UINT): WINBOOL{.stdcall, dynlib: "user32",

+proc SystemParametersInfoW*(uiAction: WINUINT, uiParam: WINUINT, pvParam: PVOID,

+                            fWinIni: WINUINT): WINBOOL{.stdcall, dynlib: "user32",

     importc: "SystemParametersInfoW".}

 proc AddFontResourceW*(para1: LPCWSTR): int32{.stdcall, dynlib: "gdi32",

     importc: "AddFontResourceW".}

@@ -15763,24 +15763,24 @@ proc EnumFontsW*(para1: HDC, para2: LPCWSTR, para3: ENUMFONTSPROC, para4: LPARAM
 proc EnumFontsW*(para1: HDC, para2: LPCWSTR, para3: ENUMFONTSPROC,

                  para4: pointer): int32{.stdcall, dynlib: "gdi32",

     importc: "EnumFontsW".}

-proc GetCharWidthW*(para1: HDC, para2: UINT, para3: UINT, para4: LPINT): WINBOOL{.

+proc GetCharWidthW*(para1: HDC, para2: WINUINT, para3: WINUINT, para4: LPINT): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "GetCharWidthW".}

-proc GetCharWidth32W*(para1: HDC, para2: UINT, para3: UINT, para4: LPINT): WINBOOL{.

+proc GetCharWidth32W*(para1: HDC, para2: WINUINT, para3: WINUINT, para4: LPINT): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "GetCharWidth32W".}

-proc GetCharWidthFloatW*(para1: HDC, para2: UINT, para3: UINT, para4: ptr float32): WINBOOL{.

+proc GetCharWidthFloatW*(para1: HDC, para2: WINUINT, para3: WINUINT, para4: ptr float32): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "GetCharWidthFloatW".}

-proc GetCharABCWidthsW*(para1: HDC, para2: UINT, para3: UINT, para4: LPABC): WINBOOL{.

+proc GetCharABCWidthsW*(para1: HDC, para2: WINUINT, para3: WINUINT, para4: LPABC): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "GetCharABCWidthsW".}

-proc GetCharABCWidthsFloatW*(para1: HDC, para2: UINT, para3: UINT,

+proc GetCharABCWidthsFloatW*(para1: HDC, para2: WINUINT, para3: WINUINT,

                              para4: LPABCFLOAT): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "GetCharABCWidthsFloatW".}

-proc GetGlyphOutlineW*(para1: HDC, para2: UINT, para3: UINT,

+proc GetGlyphOutlineW*(para1: HDC, para2: WINUINT, para3: WINUINT,

                        para4: LPGLYPHMETRICS, para5: DWORD, para6: LPVOID,

                        para7: PMAT2): DWORD{.stdcall, dynlib: "gdi32",

     importc: "GetGlyphOutlineW".}

 proc GetMetaFileW*(para1: LPCWSTR): HMETAFILE{.stdcall, dynlib: "gdi32",

     importc: "GetMetaFileW".}

-proc GetOutlineTextMetricsW*(para1: HDC, para2: UINT, para3: LPOUTLINETEXTMETRIC): UINT{.

+proc GetOutlineTextMetricsW*(para1: HDC, para2: WINUINT, para3: LPOUTLINETEXTMETRIC): WINUINT{.

     stdcall, dynlib: "gdi32", importc: "GetOutlineTextMetricsW".}

 proc GetTextExtentPointW*(para1: HDC, para2: LPCWSTR, para3: int32,

                           para4: LPSIZE): WINBOOL{.stdcall, dynlib: "gdi32",

@@ -15806,7 +15806,7 @@ proc CreateEnhMetaFileW*(para1: HDC, para2: LPCWSTR, para3: LPRECT,
     importc: "CreateEnhMetaFileW".}

 proc GetEnhMetaFileW*(para1: LPCWSTR): HENHMETAFILE{.stdcall, dynlib: "gdi32",

     importc: "GetEnhMetaFileW".}

-proc GetEnhMetaFileDescriptionW*(para1: HENHMETAFILE, para2: UINT, para3: LPWSTR): UINT{.

+proc GetEnhMetaFileDescriptionW*(para1: HENHMETAFILE, para2: WINUINT, para3: LPWSTR): WINUINT{.

     stdcall, dynlib: "gdi32", importc: "GetEnhMetaFileDescriptionW".}

 proc GetTextMetricsW*(para1: HDC, para2: LPTEXTMETRIC): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "GetTextMetricsW".}

@@ -15817,8 +15817,8 @@ proc GetObjectW*(para1: HGDIOBJ, para2: int32, para3: LPVOID): int32{.stdcall,
 proc TextOutW*(para1: HDC, para2: int32, para3: int32, para4: LPCWSTR,

                para5: int32): WINBOOL{.stdcall, dynlib: "gdi32",

                                        importc: "TextOutW".}

-proc ExtTextOutW*(para1: HDC, para2: int32, para3: int32, para4: UINT,

-                  para5: LPRECT, para6: LPCWSTR, para7: UINT, para8: LPINT): WINBOOL{.

+proc ExtTextOutW*(para1: HDC, para2: int32, para3: int32, para4: WINUINT,

+                  para5: LPRECT, para6: LPCWSTR, para7: WINUINT, para8: LPINT): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "ExtTextOutW".}

 proc PolyTextOutW*(para1: HDC, para2: PPOLYTEXT, para3: int32): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "PolyTextOutW".}

@@ -15834,7 +15834,7 @@ proc GetICMProfileW*(para1: HDC, para2: DWORD, para3: LPWSTR): WINBOOL{.stdcall,
     dynlib: "gdi32", importc: "GetICMProfileW".}

 proc SetICMProfileW*(para1: HDC, para2: LPWSTR): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "SetICMProfileW".}

-proc UpdateICMRegKeyW*(para1: DWORD, para2: DWORD, para3: LPWSTR, para4: UINT): WINBOOL{.

+proc UpdateICMRegKeyW*(para1: DWORD, para2: DWORD, para3: LPWSTR, para4: WINUINT): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "UpdateICMRegKeyW".}

 proc EnumICMProfilesW*(para1: HDC, para2: ICMENUMPROC, para3: LPARAM): int32{.

     stdcall, dynlib: "gdi32", importc: "EnumICMProfilesW".}

@@ -15843,12 +15843,12 @@ proc CreatePropertySheetPageW*(lppsp: LPCPROPSHEETPAGE): HPROPSHEETPAGE{.
 proc PropertySheetW*(lppsph: LPCPROPSHEETHEADER): int32{.stdcall,

     dynlib: "comctl32", importc: "PropertySheetW".}

 proc ImageList_LoadImageW*(hi: HINST, lpbmp: LPCWSTR, cx: int32, cGrow: int32,

-                           crMask: COLORREF, uType: UINT, uFlags: UINT): HIMAGELIST{.

+                           crMask: COLORREF, uType: WINUINT, uFlags: WINUINT): HIMAGELIST{.

     stdcall, dynlib: "comctl32", importc: "ImageList_LoadImageW".}

 proc CreateStatusWindowW*(style: LONG, lpszText: LPCWSTR, hwndParent: HWND,

-                          wID: UINT): HWND{.stdcall, dynlib: "comctl32",

+                          wID: WINUINT): HWND{.stdcall, dynlib: "comctl32",

     importc: "CreateStatusWindowW".}

-proc DrawStatusTextW*(hDC: HDC, lprc: LPRECT, pszText: LPCWSTR, uFlags: UINT){.

+proc DrawStatusTextW*(hDC: HDC, lprc: LPRECT, pszText: LPCWSTR, uFlags: WINUINT){.

     stdcall, dynlib: "comctl32", importc: "DrawStatusTextW".}

 proc GetOpenFileNameW*(para1: LPOPENFILENAME): WINBOOL{.stdcall,

     dynlib: "comdlg32", importc: "GetOpenFileNameW".}

@@ -16203,7 +16203,7 @@ proc Shell_NotifyIconW*(dwMessage: DWORD, lpData: PNotifyIconDataA): WINBOOL{.
 proc DdeCreateStringHandleW*(para1: DWORD, para2: LPCWSTR, para3: int32): HSZ{.

     stdcall, dynlib: "user32", importc: "DdeCreateStringHandleW".}

 proc DdeInitializeW*(para1: LPDWORD, para2: PFNCALLBACK, para3: DWORD,

-                     para4: DWORD): UINT{.stdcall, dynlib: "user32",

+                     para4: DWORD): WINUINT{.stdcall, dynlib: "user32",

     importc: "DdeInitializeW".}

 proc DdeQueryStringW*(para1: DWORD, para2: HSZ, para3: LPCWSTR, para4: DWORD,

                       para5: int32): DWORD{.stdcall, dynlib: "user32",

@@ -16286,7 +16286,7 @@ when defined(winUnicode):
       stdcall, dynlib: "kernel32", importc: "GetModuleFileNameW".}

   proc GetModuleHandle*(lpModuleName: LPCWSTR): HMODULE{.stdcall,

       dynlib: "kernel32", importc: "GetModuleHandleW".}

-  proc FatalAppExit*(uAction: UINT, lpMessageText: LPCWSTR){.stdcall,

+  proc FatalAppExit*(uAction: WINUINT, lpMessageText: LPCWSTR){.stdcall,

       dynlib: "kernel32", importc: "FatalAppExitW".}

   proc GetCommandLine*(): LPWSTR{.stdcall, dynlib: "kernel32",

                                   importc: "GetCommandLineW".}

@@ -16324,15 +16324,15 @@ when defined(winUnicode):
       importc: "GlobalAddAtomW".}

   proc GlobalFindAtom*(lpString: LPCWSTR): ATOM{.stdcall, dynlib: "kernel32",

       importc: "GlobalFindAtomW".}

-  proc GlobalGetAtomName*(nAtom: ATOM, lpBuffer: LPWSTR, nSize: int32): UINT{.

+  proc GlobalGetAtomName*(nAtom: ATOM, lpBuffer: LPWSTR, nSize: int32): WINUINT{.

       stdcall, dynlib: "kernel32", importc: "GlobalGetAtomNameW".}

   proc AddAtom*(lpString: LPCWSTR): ATOM{.stdcall, dynlib: "kernel32",

       importc: "AddAtomW".}

   proc FindAtom*(lpString: LPCWSTR): ATOM{.stdcall, dynlib: "kernel32",

       importc: "FindAtomW".}

-  proc GetAtomName*(nAtom: ATOM, lpBuffer: LPWSTR, nSize: int32): UINT{.stdcall,

+  proc GetAtomName*(nAtom: ATOM, lpBuffer: LPWSTR, nSize: int32): WINUINT{.stdcall,

       dynlib: "kernel32", importc: "GetAtomNameW".}

-  proc GetProfileInt*(lpAppName: LPCWSTR, lpKeyName: LPCWSTR, nDefault: WINT): UINT{.

+  proc GetProfileInt*(lpAppName: LPCWSTR, lpKeyName: LPCWSTR, nDefault: WINT): WINUINT{.

       stdcall, dynlib: "kernel32", importc: "GetProfileIntW".}

   proc GetProfileString*(lpAppName: LPCWSTR, lpKeyName: LPCWSTR,

                          lpDefault: LPCWSTR, lpReturnedString: LPWSTR,

@@ -16347,7 +16347,7 @@ when defined(winUnicode):
   proc WriteProfileSection*(lpAppName: LPCWSTR, lpString: LPCWSTR): WINBOOL{.

       stdcall, dynlib: "kernel32", importc: "WriteProfileSectionW".}

   proc GetPrivateProfileInt*(lpAppName: LPCWSTR, lpKeyName: LPCWSTR,

-                             nDefault: WINT, lpFileName: LPCWSTR): UINT{.

+                             nDefault: WINT, lpFileName: LPCWSTR): WINUINT{.

       stdcall, dynlib: "kernel32", importc: "GetPrivateProfileIntW".}

   proc GetPrivateProfileString*(lpAppName: LPCWSTR, lpKeyName: LPCWSTR,

                                 lpDefault: LPCWSTR, lpReturnedString: LPWSTR,

@@ -16362,16 +16362,16 @@ when defined(winUnicode):
   proc WritePrivateProfileSection*(lpAppName: LPCWSTR, lpString: LPCWSTR,

                                    lpFileName: LPCWSTR): WINBOOL{.stdcall,

       dynlib: "kernel32", importc: "WritePrivateProfileSectionW".}

-  proc GetDriveType*(lpRootPathName: LPCWSTR): UINT{.stdcall,

+  proc GetDriveType*(lpRootPathName: LPCWSTR): WINUINT{.stdcall,

       dynlib: "kernel32", importc: "GetDriveTypeW".}

-  proc GetSystemDirectory*(lpBuffer: LPWSTR, uSize: UINT): UINT{.stdcall,

+  proc GetSystemDirectory*(lpBuffer: LPWSTR, uSize: WINUINT): WINUINT{.stdcall,

       dynlib: "kernel32", importc: "GetSystemDirectoryW".}

   proc GetTempPath*(nBufferLength: DWORD, lpBuffer: LPWSTR): DWORD{.stdcall,

       dynlib: "kernel32", importc: "GetTempPathW".}

   proc GetTempFileName*(lpPathName: LPCWSTR, lpPrefixString: LPCWSTR,

-                        uUnique: UINT, lpTempFileName: LPWSTR): UINT{.stdcall,

+                        uUnique: WINUINT, lpTempFileName: LPWSTR): WINUINT{.stdcall,

       dynlib: "kernel32", importc: "GetTempFileNameW".}

-  proc GetWindowsDirectory*(lpBuffer: LPWSTR, uSize: UINT): UINT{.stdcall,

+  proc GetWindowsDirectory*(lpBuffer: LPWSTR, uSize: WINUINT): WINUINT{.stdcall,

       dynlib: "kernel32", importc: "GetWindowsDirectoryW".}

   proc SetCurrentDirectory*(lpPathName: LPCWSTR): WINBOOL{.stdcall,

       dynlib: "kernel32", importc: "SetCurrentDirectoryW".}

@@ -16513,7 +16513,7 @@ when defined(winUnicode):
   proc FindFirstChangeNotification*(lpPathName: LPCWSTR, bWatchSubtree: WINBOOL,

                                     dwNotifyFilter: DWORD): HANDLE{.stdcall,

       dynlib: "kernel32", importc: "FindFirstChangeNotificationW".}

-  proc IsBadStringPtr*(lpsz: LPCWSTR, ucchMax: UINT): WINBOOL{.stdcall,

+  proc IsBadStringPtr*(lpsz: LPCWSTR, ucchMax: WINUINT): WINBOOL{.stdcall,

       dynlib: "kernel32", importc: "IsBadStringPtrW".}

   proc LookupAccountSid*(lpSystemName: LPCWSTR, Sid: PSID, Name: LPWSTR,

                          cbName: LPDWORD, ReferencedDomainName: LPWSTR,

@@ -16553,7 +16553,7 @@ when defined(winUnicode):
       dynlib: "kernel32", importc: "SetComputerNameW".}

   proc GetUserName*(lpBuffer: LPWSTR, nSize: LPDWORD): WINBOOL{.stdcall,

       dynlib: "advapi32", importc: "GetUserNameW".}

-  proc LoadKeyboardLayout*(pwszKLID: LPCWSTR, Flags: UINT): HKL{.stdcall,

+  proc LoadKeyboardLayout*(pwszKLID: LPCWSTR, Flags: WINUINT): HKL{.stdcall,

       dynlib: "user32", importc: "LoadKeyboardLayoutW".}

   proc GetKeyboardLayoutName*(pwszKLID: LPWSTR): WINBOOL{.stdcall,

       dynlib: "user32", importc: "GetKeyboardLayoutNameW".}

@@ -16581,36 +16581,36 @@ when defined(winUnicode):
   proc SetUserObjectInformation*(hObj: HANDLE, nIndex: int32, pvInfo: PVOID,

                                  nLength: DWORD): WINBOOL{.stdcall,

       dynlib: "user32", importc: "SetUserObjectInformationW".}

-  proc RegisterWindowMessage*(lpString: LPCWSTR): UINT{.stdcall,

+  proc RegisterWindowMessage*(lpString: LPCWSTR): WINUINT{.stdcall,

       dynlib: "user32", importc: "RegisterWindowMessageW".}

-  proc GetMessage*(lpMsg: LPMSG, wnd: HWND, wMsgFilterMin: UINT,

-                   wMsgFilterMax: UINT): WINBOOL{.stdcall, dynlib: "user32",

+  proc GetMessage*(lpMsg: LPMSG, wnd: HWND, wMsgFilterMin: WINUINT,

+                   wMsgFilterMax: WINUINT): WINBOOL{.stdcall, dynlib: "user32",

       importc: "GetMessageW".}

   proc DispatchMessage*(lpMsg: LPMSG): LONG{.stdcall, dynlib: "user32",

       importc: "DispatchMessageW".}

-  proc PeekMessage*(lpMsg: LPMSG, wnd: HWND, wMsgFilterMin: UINT,

-                    wMsgFilterMax: UINT, wRemoveMsg: UINT): WINBOOL{.stdcall,

+  proc PeekMessage*(lpMsg: LPMSG, wnd: HWND, wMsgFilterMin: WINUINT,

+                    wMsgFilterMax: WINUINT, wRemoveMsg: WINUINT): WINBOOL{.stdcall,

       dynlib: "user32", importc: "PeekMessageW".}

-  proc SendMessage*(wnd: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM): LRESULT{.

+  proc SendMessage*(wnd: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM): LRESULT{.

       stdcall, dynlib: "user32", importc: "SendMessageW".}

-  proc SendMessageTimeout*(wnd: HWND, Msg: UINT, wp: WPARAM,

-                           lp: LPARAM, fuFlags: UINT, uTimeout: UINT,

+  proc SendMessageTimeout*(wnd: HWND, Msg: WINUINT, wp: WPARAM,

+                           lp: LPARAM, fuFlags: WINUINT, uTimeout: WINUINT,

                            lpdwResult: LPDWORD): LRESULT{.stdcall,

       dynlib: "user32", importc: "SendMessageTimeoutW".}

-  proc SendNotifyMessage*(wnd: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM): WINBOOL{.

+  proc SendNotifyMessage*(wnd: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM): WINBOOL{.

       stdcall, dynlib: "user32", importc: "SendNotifyMessageW".}

-  proc SendMessageCallback*(wnd: HWND, Msg: UINT, wp: WPARAM,

+  proc SendMessageCallback*(wnd: HWND, Msg: WINUINT, wp: WPARAM,

                             lp: LPARAM, lpResultCallBack: SENDASYNCPROC,

                             dwData: DWORD): WINBOOL{.stdcall, dynlib: "user32",

       importc: "SendMessageCallbackW".}

-  proc PostMessage*(wnd: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM): WINBOOL{.

+  proc PostMessage*(wnd: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM): WINBOOL{.

       stdcall, dynlib: "user32", importc: "PostMessageW".}

-  proc PostThreadMessage*(idThread: DWORD, Msg: UINT, wp: WPARAM,

+  proc PostThreadMessage*(idThread: DWORD, Msg: WINUINT, wp: WPARAM,

                           lp: LPARAM): WINBOOL{.stdcall, dynlib: "user32",

       importc: "PostThreadMessageW".}

-  proc DefWindowProc*(wnd: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM): LRESULT{.

+  proc DefWindowProc*(wnd: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM): LRESULT{.

       stdcall, dynlib: "user32", importc: "DefWindowProcW".}

-  proc CallWindowProc*(lpPrevWndFunc: WNDPROC, wnd: HWND, Msg: UINT,

+  proc CallWindowProc*(lpPrevWndFunc: WNDPROC, wnd: HWND, Msg: WINUINT,

                        wp: WPARAM, lp: LPARAM): LRESULT{.stdcall,

       dynlib: "user32", importc: "CallWindowProcW".}

   proc RegisterClass*(lpWndClass: LPWNDCLASS): ATOM{.stdcall, dynlib: "user32",

@@ -16650,18 +16650,18 @@ when defined(winUnicode):
   proc SetDlgItemText*(hDlg: HWND, nIDDlgItem: int32, lpString: LPCWSTR): WINBOOL{.

       stdcall, dynlib: "user32", importc: "SetDlgItemTextW".}

   proc GetDlgItemText*(hDlg: HWND, nIDDlgItem: int32, lpString: LPWSTR,

-                       nMaxCount: int32): UINT{.stdcall, dynlib: "user32",

+                       nMaxCount: int32): WINUINT{.stdcall, dynlib: "user32",

       importc: "GetDlgItemTextW".}

-  proc SendDlgItemMessage*(hDlg: HWND, nIDDlgItem: int32, Msg: UINT,

+  proc SendDlgItemMessage*(hDlg: HWND, nIDDlgItem: int32, Msg: WINUINT,

                            wp: WPARAM, lp: LPARAM): LONG{.stdcall,

       dynlib: "user32", importc: "SendDlgItemMessageW".}

-  proc DefDlgProc*(hDlg: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM): LRESULT{.

+  proc DefDlgProc*(hDlg: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM): LRESULT{.

       stdcall, dynlib: "user32", importc: "DefDlgProcW".}

   proc CallMsgFilter*(lpMsg: LPMSG, nCode: int32): WINBOOL{.stdcall,

       dynlib: "user32", importc: "CallMsgFilterW".}

-  proc RegisterClipboardFormat*(lpszFormat: LPCWSTR): UINT{.stdcall,

+  proc RegisterClipboardFormat*(lpszFormat: LPCWSTR): WINUINT{.stdcall,

       dynlib: "user32", importc: "RegisterClipboardFormatW".}

-  proc GetClipboardFormatName*(format: UINT, lpszFormatName: LPWSTR,

+  proc GetClipboardFormatName*(format: WINUINT, lpszFormatName: LPWSTR,

                                cchMaxCount: int32): int32{.stdcall,

       dynlib: "user32", importc: "GetClipboardFormatNameW".}

   proc CharToOem*(lpszSrc: LPCWSTR, lpszDst: LPSTR): WINBOOL{.stdcall,

@@ -16698,9 +16698,9 @@ when defined(winUnicode):
                                      importc: "VkKeyScanW".}

   proc VkKeyScanEx*(ch: WCHAR, dwhkl: HKL): SHORT{.stdcall, dynlib: "user32",

       importc: "VkKeyScanExW".}

-  proc MapVirtualKey*(uCode: UINT, uMapType: UINT): UINT{.stdcall,

+  proc MapVirtualKey*(uCode: WINUINT, uMapType: WINUINT): WINUINT{.stdcall,

       dynlib: "user32", importc: "MapVirtualKeyW".}

-  proc MapVirtualKeyEx*(uCode: UINT, uMapType: UINT, dwhkl: HKL): UINT{.stdcall,

+  proc MapVirtualKeyEx*(uCode: WINUINT, uMapType: WINUINT, dwhkl: HKL): WINUINT{.stdcall,

       dynlib: "user32", importc: "MapVirtualKeyExW".}

   proc LoadAccelerators*(hInstance: HINST, lpTableName: LPCWSTR): HACCEL{.

       stdcall, dynlib: "user32", importc: "LoadAcceleratorsW".}

@@ -16715,35 +16715,35 @@ when defined(winUnicode):
       dynlib: "user32", importc: "LoadMenuW".}

   proc LoadMenuIndirect*(lpMenuTemplate: LPMENUTEMPLATE): HMENU{.stdcall,

       dynlib: "user32", importc: "LoadMenuIndirectW".}

-  proc ChangeMenu*(menu: HMENU, cmd: UINT, lpszNewItem: LPCWSTR,

-                   cmdInsert: UINT, flags: UINT): WINBOOL{.stdcall,

+  proc ChangeMenu*(menu: HMENU, cmd: WINUINT, lpszNewItem: LPCWSTR,

+                   cmdInsert: WINUINT, flags: WINUINT): WINBOOL{.stdcall,

       dynlib: "user32", importc: "ChangeMenuW".}

-  proc GetMenuString*(menu: HMENU, uIDItem: UINT, lpString: LPWSTR,

-                      nMaxCount: int32, uFlag: UINT): int32{.stdcall,

+  proc GetMenuString*(menu: HMENU, uIDItem: WINUINT, lpString: LPWSTR,

+                      nMaxCount: int32, uFlag: WINUINT): int32{.stdcall,

       dynlib: "user32", importc: "GetMenuStringW".}

-  proc InsertMenu*(menu: HMENU, uPosition: UINT, uFlags: UINT,

-                   uIDNewItem: UINT, lpNewItem: LPCWSTR): WINBOOL{.stdcall,

+  proc InsertMenu*(menu: HMENU, uPosition: WINUINT, uFlags: WINUINT,

+                   uIDNewItem: WINUINT, lpNewItem: LPCWSTR): WINBOOL{.stdcall,

       dynlib: "user32", importc: "InsertMenuW".}

-  proc AppendMenu*(menu: HMENU, uFlags: UINT, uIDNewItem: UINT,

+  proc AppendMenu*(menu: HMENU, uFlags: WINUINT, uIDNewItem: WINUINT,

                    lpNewItem: LPCWSTR): WINBOOL{.stdcall, dynlib: "user32",

       importc: "AppendMenuW".}

-  proc ModifyMenu*(hMnu: HMENU, uPosition: UINT, uFlags: UINT, uIDNewItem: UINT,

+  proc ModifyMenu*(hMnu: HMENU, uPosition: WINUINT, uFlags: WINUINT, uIDNewItem: WINUINT,

                    lpNewItem: LPCWSTR): WINBOOL{.stdcall, dynlib: "user32",

       importc: "ModifyMenuW".}

-  proc InsertMenuItem*(para1: HMENU, para2: UINT, para3: WINBOOL,

+  proc InsertMenuItem*(para1: HMENU, para2: WINUINT, para3: WINBOOL,

                        para4: LPCMENUITEMINFO): WINBOOL{.stdcall,

       dynlib: "user32", importc: "InsertMenuItemW".}

-  proc GetMenuItemInfo*(para1: HMENU, para2: UINT, para3: WINBOOL,

+  proc GetMenuItemInfo*(para1: HMENU, para2: WINUINT, para3: WINBOOL,

                         para4: LPMENUITEMINFO): WINBOOL{.stdcall,

       dynlib: "user32", importc: "GetMenuItemInfoW".}

-  proc SetMenuItemInfo*(para1: HMENU, para2: UINT, para3: WINBOOL,

+  proc SetMenuItemInfo*(para1: HMENU, para2: WINUINT, para3: WINBOOL,

                         para4: LPCMENUITEMINFO): WINBOOL{.stdcall,

       dynlib: "user32", importc: "SetMenuItemInfoW".}

   proc DrawText*(hDC: HDC, lpString: LPCWSTR, nCount: int32, lpRect: LPRECT,

-                 uFormat: UINT): int32{.stdcall, dynlib: "user32",

+                 uFormat: WINUINT): int32{.stdcall, dynlib: "user32",

                                         importc: "DrawTextW".}

   proc DrawTextEx*(para1: HDC, para2: LPWSTR, para3: int32, para4: LPRECT,

-                   para5: UINT, para6: LPDRAWTEXTPARAMS): int32{.stdcall,

+                   para5: WINUINT, para6: LPDRAWTEXTPARAMS): int32{.stdcall,

       dynlib: "user32", importc: "DrawTextExW".}

   proc GrayString*(hDC: HDC, hBrush: HBRUSH, lpOutputFunc: GRAYSTRINGPROC,

                    lpData: LPARAM, nCount: int32, X: int32, Y: int32,

@@ -16751,7 +16751,7 @@ when defined(winUnicode):
       dynlib: "user32", importc: "GrayStringW".}

   proc DrawState*(para1: HDC, para2: HBRUSH, para3: DRAWSTATEPROC,

                   para4: LPARAM, para5: WPARAM, para6: int32, para7: int32,

-                  para8: int32, para9: int32, para10: UINT): WINBOOL{.stdcall,

+                  para8: int32, para9: int32, para10: WINUINT): WINBOOL{.stdcall,

       dynlib: "user32", importc: "DrawStateW".}

   proc TabbedTextOut*(hDC: HDC, X: int32, Y: int32, lpString: LPCWSTR,

                       nCount: int32, nTabPositions: int32,

@@ -16776,10 +16776,10 @@ when defined(winUnicode):
       stdcall, dynlib: "user32", importc: "GetWindowTextW".}

   proc GetWindowTextLength*(wnd: HWND): int32{.stdcall, dynlib: "user32",

       importc: "GetWindowTextLengthW".}

-  proc MessageBox*(wnd: HWND, lpText: LPCWSTR, lpCaption: LPCWSTR, uType: UINT): int32{.

+  proc MessageBox*(wnd: HWND, lpText: LPCWSTR, lpCaption: LPCWSTR, uType: WINUINT): int32{.

       stdcall, dynlib: "user32", importc: "MessageBoxW".}

   proc MessageBoxEx*(wnd: HWND, lpText: LPCWSTR, lpCaption: LPCWSTR,

-                     uType: UINT, wLanguageId: int16): int32{.stdcall,

+                     uType: WINUINT, wLanguageId: int16): int32{.stdcall,

       dynlib: "user32", importc: "MessageBoxExW".}

   proc MessageBoxIndirect*(para1: LPMSGBOXPARAMS): int32{.stdcall,

       dynlib: "user32", importc: "MessageBoxIndirectW".}

@@ -16826,45 +16826,45 @@ when defined(winUnicode):
       dynlib: "user32", importc: "LoadCursorFromFileW".}

   proc LoadIcon*(hInstance: HINST, lpIconName: LPCWSTR): HICON{.stdcall,

       dynlib: "user32", importc: "LoadIconW".}

-  proc LoadImage*(para1: HINST, para2: LPCWSTR, para3: UINT, para4: int32,

-                  para5: int32, para6: UINT): HANDLE{.stdcall, dynlib: "user32",

+  proc LoadImage*(para1: HINST, para2: LPCWSTR, para3: WINUINT, para4: int32,

+                  para5: int32, para6: WINUINT): HANDLE{.stdcall, dynlib: "user32",

       importc: "LoadImageW".}

-  proc LoadString*(hInstance: HINST, uID: UINT, lpBuffer: LPWSTR,

+  proc LoadString*(hInstance: HINST, uID: WINUINT, lpBuffer: LPWSTR,

                    nBufferMax: int32): int32{.stdcall, dynlib: "user32",

       importc: "LoadStringW".}

   proc IsDialogMessage*(hDlg: HWND, lpMsg: LPMSG): WINBOOL{.stdcall,

       dynlib: "user32", importc: "IsDialogMessageW".}

   proc DlgDirList*(hDlg: HWND, lpPathSpec: LPWSTR, nIDListBox: int32,

-                   nIDStaticPath: int32, uFileType: UINT): int32{.stdcall,

+                   nIDStaticPath: int32, uFileType: WINUINT): int32{.stdcall,

       dynlib: "user32", importc: "DlgDirListW".}

   proc DlgDirSelectEx*(hDlg: HWND, lpString: LPWSTR, nCount: int32,

                        nIDListBox: int32): WINBOOL{.stdcall, dynlib: "user32",

       importc: "DlgDirSelectExW".}

   proc DlgDirListComboBox*(hDlg: HWND, lpPathSpec: LPWSTR, nIDComboBox: int32,

-                           nIDStaticPath: int32, uFiletype: UINT): int32{.

+                           nIDStaticPath: int32, uFiletype: WINUINT): int32{.

       stdcall, dynlib: "user32", importc: "DlgDirListComboBoxW".}

   proc DlgDirSelectComboBoxEx*(hDlg: HWND, lpString: LPWSTR, nCount: int32,

                                nIDComboBox: int32): WINBOOL{.stdcall,

       dynlib: "user32", importc: "DlgDirSelectComboBoxExW".}

-  proc DefFrameProc*(wnd: HWND, hWndMDIClient: HWND, uMsg: UINT,

+  proc DefFrameProc*(wnd: HWND, hWndMDIClient: HWND, uMsg: WINUINT,

                      wp: WPARAM, lp: LPARAM): LRESULT{.stdcall,

       dynlib: "user32", importc: "DefFrameProcW".}

-  proc DefMDIChildProc*(wnd: HWND, uMsg: UINT, wp: WPARAM, lp: LPARAM): LRESULT{.

+  proc DefMDIChildProc*(wnd: HWND, uMsg: WINUINT, wp: WPARAM, lp: LPARAM): LRESULT{.

       stdcall, dynlib: "user32", importc: "DefMDIChildProcW".}

   proc CreateMDIWindow*(lpClassName: LPWSTR, lpWindowName: LPWSTR,

                         dwStyle: DWORD, X: int32, Y: int32, nWidth: int32,

                         nHeight: int32, hWndParent: HWND, hInstance: HINST,

                         lp: LPARAM): HWND{.stdcall, dynlib: "user32",

       importc: "CreateMDIWindowW".}

-  proc WinHelp*(hWndMain: HWND, lpszHelp: LPCWSTR, uCommand: UINT, dwData: DWORD): WINBOOL{.

+  proc WinHelp*(hWndMain: HWND, lpszHelp: LPCWSTR, uCommand: WINUINT, dwData: DWORD): WINBOOL{.

       stdcall, dynlib: "user32", importc: "WinHelpW".}

   proc ChangeDisplaySettings*(lpDevMode: LPDEVMODE, dwFlags: DWORD): LONG{.

       stdcall, dynlib: "user32", importc: "ChangeDisplaySettingsW".}

   proc EnumDisplaySettings*(lpszDeviceName: LPCWSTR, iModeNum: DWORD,

                             lpDevMode: LPDEVMODEW): WINBOOL{.stdcall,

       dynlib: "user32", importc: "EnumDisplaySettingsW".}

-  proc SystemParametersInfo*(uiAction: UINT, uiParam: UINT, pvParam: PVOID,

-                             fWinIni: UINT): WINBOOL{.stdcall, dynlib: "user32",

+  proc SystemParametersInfo*(uiAction: WINUINT, uiParam: WINUINT, pvParam: PVOID,

+                             fWinIni: WINUINT): WINBOOL{.stdcall, dynlib: "user32",

       importc: "SystemParametersInfoW".}

   proc AddFontResource*(para1: LPCWSTR): int32{.stdcall, dynlib: "gdi32",

       importc: "AddFontResourceW".}

@@ -16899,25 +16899,25 @@ when defined(winUnicode):
   proc EnumFonts*(para1: HDC, para2: LPCWSTR, para3: ENUMFONTSPROC,

                   para4: pointer): int32{.stdcall, dynlib: "gdi32",

       importc: "EnumFontsW".}

-  proc GetCharWidth*(para1: HDC, para2: UINT, para3: UINT, para4: LPINT): WINBOOL{.

+  proc GetCharWidth*(para1: HDC, para2: WINUINT, para3: WINUINT, para4: LPINT): WINBOOL{.

       stdcall, dynlib: "gdi32", importc: "GetCharWidthW".}

-  proc GetCharWidth32*(para1: HDC, para2: UINT, para3: UINT, para4: LPINT): WINBOOL{.

+  proc GetCharWidth32*(para1: HDC, para2: WINUINT, para3: WINUINT, para4: LPINT): WINBOOL{.

       stdcall, dynlib: "gdi32", importc: "GetCharWidth32W".}

-  proc GetCharWidthFloat*(para1: HDC, para2: UINT, para3: UINT, para4: ptr float32): WINBOOL{.

+  proc GetCharWidthFloat*(para1: HDC, para2: WINUINT, para3: WINUINT, para4: ptr float32): WINBOOL{.

       stdcall, dynlib: "gdi32", importc: "GetCharWidthFloatW".}

-  proc GetCharABCWidths*(para1: HDC, para2: UINT, para3: UINT, para4: LPABC): WINBOOL{.

+  proc GetCharABCWidths*(para1: HDC, para2: WINUINT, para3: WINUINT, para4: LPABC): WINBOOL{.

       stdcall, dynlib: "gdi32", importc: "GetCharABCWidthsW".}

-  proc GetCharABCWidthsFloat*(para1: HDC, para2: UINT, para3: UINT,

+  proc GetCharABCWidthsFloat*(para1: HDC, para2: WINUINT, para3: WINUINT,

                               para4: LPABCFLOAT): WINBOOL{.stdcall,

       dynlib: "gdi32", importc: "GetCharABCWidthsFloatW".}

-  proc GetGlyphOutline*(para1: HDC, para2: UINT, para3: UINT,

+  proc GetGlyphOutline*(para1: HDC, para2: WINUINT, para3: WINUINT,

                         para4: LPGLYPHMETRICS, para5: DWORD, para6: LPVOID,

                         para7: PMAT2): DWORD{.stdcall, dynlib: "gdi32",

       importc: "GetGlyphOutlineW".}

   proc GetMetaFile*(para1: LPCWSTR): HMETAFILE{.stdcall, dynlib: "gdi32",

       importc: "GetMetaFileW".}

-  proc GetOutlineTextMetrics*(para1: HDC, para2: UINT,

-                              para3: LPOUTLINETEXTMETRIC): UINT{.stdcall,

+  proc GetOutlineTextMetrics*(para1: HDC, para2: WINUINT,

+                              para3: LPOUTLINETEXTMETRIC): WINUINT{.stdcall,

       dynlib: "gdi32", importc: "GetOutlineTextMetricsW".}

   proc GetTextExtentPoint*(para1: HDC, para2: LPCWSTR, para3: int32,

                            para4: LPSIZE): WINBOOL{.stdcall, dynlib: "gdi32",

@@ -16943,8 +16943,8 @@ when defined(winUnicode):
       importc: "CreateEnhMetaFileW".}

   proc GetEnhMetaFile*(para1: LPCWSTR): HENHMETAFILE{.stdcall, dynlib: "gdi32",

       importc: "GetEnhMetaFileW".}

-  proc GetEnhMetaFileDescription*(para1: HENHMETAFILE, para2: UINT,

-                                  para3: LPWSTR): UINT{.stdcall,

+  proc GetEnhMetaFileDescription*(para1: HENHMETAFILE, para2: WINUINT,

+                                  para3: LPWSTR): WINUINT{.stdcall,

       dynlib: "gdi32", importc: "GetEnhMetaFileDescriptionW".}

   proc GetTextMetrics*(para1: HDC, para2: LPTEXTMETRIC): WINBOOL{.stdcall,

       dynlib: "gdi32", importc: "GetTextMetricsW".}

@@ -16955,8 +16955,8 @@ when defined(winUnicode):
   proc TextOut*(para1: HDC, para2: int32, para3: int32, para4: LPCWSTR,

                 para5: int32): WINBOOL{.stdcall, dynlib: "gdi32",

                                         importc: "TextOutW".}

-  proc ExtTextOut*(para1: HDC, para2: int32, para3: int32, para4: UINT,

-                   para5: LPRECT, para6: LPCWSTR, para7: UINT, para8: LPINT): WINBOOL{.

+  proc ExtTextOut*(para1: HDC, para2: int32, para3: int32, para4: WINUINT,

+                   para5: LPRECT, para6: LPCWSTR, para7: WINUINT, para8: LPINT): WINBOOL{.

       stdcall, dynlib: "gdi32", importc: "ExtTextOutW".}

   proc PolyTextOut*(para1: HDC, para2: PPOLYTEXT, para3: int32): WINBOOL{.

       stdcall, dynlib: "gdi32", importc: "PolyTextOutW".}

@@ -16974,7 +16974,7 @@ when defined(winUnicode):
   proc SetICMProfile*(para1: HDC, para2: LPWSTR): WINBOOL{.stdcall,

 

       dynlib: "gdi32", importc: "SetICMProfileW".}

-  proc UpdateICMRegKey*(para1: DWORD, para2: DWORD, para3: LPWSTR, para4: UINT): WINBOOL{.

+  proc UpdateICMRegKey*(para1: DWORD, para2: DWORD, para3: LPWSTR, para4: WINUINT): WINBOOL{.

       stdcall, dynlib: "gdi32", importc: "UpdateICMRegKeyW".}

   proc EnumICMProfiles*(para1: HDC, para2: ICMENUMPROC, para3: LPARAM): int32{.

       stdcall, dynlib: "gdi32", importc: "EnumICMProfilesW".}

@@ -16983,12 +16983,12 @@ when defined(winUnicode):
   proc PropertySheet*(lppsph: LPCPROPSHEETHEADER): int32{.stdcall,

       dynlib: "comctl32", importc: "PropertySheetW".}

   proc ImageList_LoadImage*(hi: HINST, lpbmp: LPCWSTR, cx: int32, cGrow: int32,

-                            crMask: COLORREF, uType: UINT, uFlags: UINT): HIMAGELIST{.

+                            crMask: COLORREF, uType: WINUINT, uFlags: WINUINT): HIMAGELIST{.

       stdcall, dynlib: "comctl32", importc: "ImageList_LoadImageW".}

   proc CreateStatusWindow*(style: LONG, lpszText: LPCWSTR, hwndParent: HWND,

-                           wID: UINT): HWND{.stdcall, dynlib: "comctl32",

+                           wID: WINUINT): HWND{.stdcall, dynlib: "comctl32",

       importc: "CreateStatusWindowW".}

-  proc DrawStatusText*(hDC: HDC, lprc: LPRECT, pszText: LPCWSTR, uFlags: UINT){.

+  proc DrawStatusText*(hDC: HDC, lprc: LPRECT, pszText: LPCWSTR, uFlags: WINUINT){.

       stdcall, dynlib: "comctl32", importc: "DrawStatusTextW".}

   proc GetOpenFileName*(para1: LPOPENFILENAME): WINBOOL{.stdcall,

       dynlib: "comdlg32", importc: "GetOpenFileNameW".}

@@ -17348,7 +17348,7 @@ when defined(winUnicode):
   proc DdeCreateStringHandle*(para1: DWORD, para2: LPCWSTR, para3: int32): HSZ{.

       stdcall, dynlib: "user32", importc: "DdeCreateStringHandleW".}

   proc DdeInitialize*(para1: LPDWORD, para2: PFNCALLBACK, para3: DWORD,

-                      para4: DWORD): UINT{.stdcall, dynlib: "user32",

+                      para4: DWORD): WINUINT{.stdcall, dynlib: "user32",

       importc: "DdeInitializeW".}

   proc DdeQueryString*(para1: DWORD, para2: HSZ, para3: LPCWSTR, para4: DWORD,

                        para5: int32): DWORD{.stdcall, dynlib: "user32",

@@ -17429,7 +17429,7 @@ else:
       stdcall, dynlib: "kernel32", importc: "GetModuleFileNameA".}

   proc GetModuleHandle*(lpModuleName: LPCSTR): HMODULE{.stdcall,

       dynlib: "kernel32", importc: "GetModuleHandleA".}

-  proc FatalAppExit*(uAction: UINT, lpMessageText: LPCSTR){.stdcall,

+  proc FatalAppExit*(uAction: WINUINT, lpMessageText: LPCSTR){.stdcall,

       dynlib: "kernel32", importc: "FatalAppExitA".}

   proc GetCommandLine*(): LPSTR{.stdcall, dynlib: "kernel32",

                                  importc: "GetCommandLineA".}

@@ -17466,15 +17466,15 @@ else:
       importc: "GlobalAddAtomA".}

   proc GlobalFindAtom*(lpString: LPCSTR): ATOM{.stdcall, dynlib: "kernel32",

       importc: "GlobalFindAtomA".}

-  proc GlobalGetAtomName*(nAtom: ATOM, lpBuffer: LPSTR, nSize: int32): UINT{.

+  proc GlobalGetAtomName*(nAtom: ATOM, lpBuffer: LPSTR, nSize: int32): WINUINT{.

       stdcall, dynlib: "kernel32", importc: "GlobalGetAtomNameA".}

   proc AddAtom*(lpString: LPCSTR): ATOM{.stdcall, dynlib: "kernel32",

       importc: "AddAtomA".}

   proc FindAtom*(lpString: LPCSTR): ATOM{.stdcall, dynlib: "kernel32",

       importc: "FindAtomA".}

-  proc GetAtomName*(nAtom: ATOM, lpBuffer: LPSTR, nSize: int32): UINT{.stdcall,

+  proc GetAtomName*(nAtom: ATOM, lpBuffer: LPSTR, nSize: int32): WINUINT{.stdcall,

       dynlib: "kernel32", importc: "GetAtomNameA".}

-  proc GetProfileInt*(lpAppName: LPCSTR, lpKeyName: LPCSTR, nDefault: WINT): UINT{.

+  proc GetProfileInt*(lpAppName: LPCSTR, lpKeyName: LPCSTR, nDefault: WINT): WINUINT{.

       stdcall, dynlib: "kernel32", importc: "GetProfileIntA".}

   proc GetProfileString*(lpAppName: LPCSTR, lpKeyName: LPCSTR,

                          lpDefault: LPCSTR, lpReturnedString: LPSTR,

@@ -17489,7 +17489,7 @@ else:
   proc WriteProfileSection*(lpAppName: LPCSTR, lpString: LPCSTR): WINBOOL{.

       stdcall, dynlib: "kernel32", importc: "WriteProfileSectionA".}

   proc GetPrivateProfileInt*(lpAppName: LPCSTR, lpKeyName: LPCSTR,

-                             nDefault: WINT, lpFileName: LPCSTR): UINT{.stdcall,

+                             nDefault: WINT, lpFileName: LPCSTR): WINUINT{.stdcall,

       dynlib: "kernel32", importc: "GetPrivateProfileIntA".}

   proc GetPrivateProfileString*(lpAppName: LPCSTR, lpKeyName: LPCSTR,

                                 lpDefault: LPCSTR, lpReturnedString: LPSTR,

@@ -17504,16 +17504,16 @@ else:
   proc WritePrivateProfileSection*(lpAppName: LPCSTR, lpString: LPCSTR,

                                    lpFileName: LPCSTR): WINBOOL{.stdcall,

       dynlib: "kernel32", importc: "WritePrivateProfileSectionA".}

-  proc GetDriveType*(lpRootPathName: LPCSTR): UINT{.stdcall, dynlib: "kernel32",

+  proc GetDriveType*(lpRootPathName: LPCSTR): WINUINT{.stdcall, dynlib: "kernel32",

       importc: "GetDriveTypeA".}

-  proc GetSystemDirectory*(lpBuffer: LPSTR, uSize: UINT): UINT{.stdcall,

+  proc GetSystemDirectory*(lpBuffer: LPSTR, uSize: WINUINT): WINUINT{.stdcall,

       dynlib: "kernel32", importc: "GetSystemDirectoryA".}

   proc GetTempPath*(nBufferLength: DWORD, lpBuffer: LPSTR): DWORD{.stdcall,

       dynlib: "kernel32", importc: "GetTempPathA".}

   proc GetTempFileName*(lpPathName: LPCSTR, lpPrefixString: LPCSTR,

-                        uUnique: UINT, lpTempFileName: LPSTR): UINT{.stdcall,

+                        uUnique: WINUINT, lpTempFileName: LPSTR): WINUINT{.stdcall,

       dynlib: "kernel32", importc: "GetTempFileNameA".}

-  proc GetWindowsDirectory*(lpBuffer: LPSTR, uSize: UINT): UINT{.stdcall,

+  proc GetWindowsDirectory*(lpBuffer: LPSTR, uSize: WINUINT): WINUINT{.stdcall,

       dynlib: "kernel32", importc: "GetWindowsDirectoryA".}

   proc SetCurrentDirectory*(lpPathName: LPCSTR): WINBOOL{.stdcall,

       dynlib: "kernel32", importc: "SetCurrentDirectoryA".}

@@ -17654,7 +17654,7 @@ else:
   proc FindFirstChangeNotification*(lpPathName: LPCSTR, bWatchSubtree: WINBOOL,

                                     dwNotifyFilter: DWORD): HANDLE{.stdcall,

       dynlib: "kernel32", importc: "FindFirstChangeNotificationA".}

-  proc IsBadStringPtr*(lpsz: LPCSTR, ucchMax: UINT): WINBOOL{.stdcall,

+  proc IsBadStringPtr*(lpsz: LPCSTR, ucchMax: WINUINT): WINBOOL{.stdcall,

       dynlib: "kernel32", importc: "IsBadStringPtrA".}

   proc LookupAccountSid*(lpSystemName: LPCSTR, Sid: PSID, Name: LPSTR,

                          cbName: LPDWORD, ReferencedDomainName: LPSTR,

@@ -17694,7 +17694,7 @@ else:
       dynlib: "advapi32", importc: "GetUserNameA".}

   proc wvsprintf*(para1: LPSTR, para2: LPCSTR, arglist: va_list): int32{.

       stdcall, dynlib: "user32", importc: "wvsprintfA".}

-  proc LoadKeyboardLayout*(pwszKLID: LPCSTR, Flags: UINT): HKL{.stdcall,

+  proc LoadKeyboardLayout*(pwszKLID: LPCSTR, Flags: WINUINT): HKL{.stdcall,

       dynlib: "user32", importc: "LoadKeyboardLayoutA".}

   proc GetKeyboardLayoutName*(pwszKLID: LPSTR): WINBOOL{.stdcall,

       dynlib: "user32", importc: "GetKeyboardLayoutNameA".}

@@ -17722,36 +17722,36 @@ else:
   proc SetUserObjectInformation*(hObj: HANDLE, nIndex: int32, pvInfo: PVOID,

                                  nLength: DWORD): WINBOOL{.stdcall,

       dynlib: "user32", importc: "SetUserObjectInformationA".}

-  proc RegisterWindowMessage*(lpString: LPCSTR): UINT{.stdcall,

+  proc RegisterWindowMessage*(lpString: LPCSTR): WINUINT{.stdcall,

       dynlib: "user32", importc: "RegisterWindowMessageA".}

-  proc GetMessage*(lpMsg: LPMSG, wnd: HWND, wMsgFilterMin: UINT,

-                   wMsgFilterMax: UINT): WINBOOL{.stdcall, dynlib: "user32",

+  proc GetMessage*(lpMsg: LPMSG, wnd: HWND, wMsgFilterMin: WINUINT,

+                   wMsgFilterMax: WINUINT): WINBOOL{.stdcall, dynlib: "user32",

       importc: "GetMessageA".}

   proc DispatchMessage*(lpMsg: LPMSG): LONG{.stdcall, dynlib: "user32",

       importc: "DispatchMessageA".}

-  proc PeekMessage*(lpMsg: LPMSG, wnd: HWND, wMsgFilterMin: UINT,

-                    wMsgFilterMax: UINT, wRemoveMsg: UINT): WINBOOL{.stdcall,

+  proc PeekMessage*(lpMsg: LPMSG, wnd: HWND, wMsgFilterMin: WINUINT,

+                    wMsgFilterMax: WINUINT, wRemoveMsg: WINUINT): WINBOOL{.stdcall,

       dynlib: "user32", importc: "PeekMessageA".}

-  proc SendMessage*(wnd: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM): LRESULT{.

+  proc SendMessage*(wnd: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM): LRESULT{.

       stdcall, dynlib: "user32", importc: "SendMessageA".}

-  proc SendMessageTimeout*(wnd: HWND, Msg: UINT, wp: WPARAM,

-                           lp: LPARAM, fuFlags: UINT, uTimeout: UINT,

+  proc SendMessageTimeout*(wnd: HWND, Msg: WINUINT, wp: WPARAM,

+                           lp: LPARAM, fuFlags: WINUINT, uTimeout: WINUINT,

                            lpdwResult: LPDWORD): LRESULT{.stdcall,

       dynlib: "user32", importc: "SendMessageTimeoutA".}

-  proc SendNotifyMessage*(wnd: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM): WINBOOL{.

+  proc SendNotifyMessage*(wnd: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM): WINBOOL{.

       stdcall, dynlib: "user32", importc: "SendNotifyMessageA".}

-  proc SendMessageCallback*(wnd: HWND, Msg: UINT, wp: WPARAM,

+  proc SendMessageCallback*(wnd: HWND, Msg: WINUINT, wp: WPARAM,

                             lp: LPARAM, lpResultCallBack: SENDASYNCPROC,

                             dwData: DWORD): WINBOOL{.stdcall, dynlib: "user32",

       importc: "SendMessageCallbackA".}

-  proc PostMessage*(wnd: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM): WINBOOL{.

+  proc PostMessage*(wnd: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM): WINBOOL{.

       stdcall, dynlib: "user32", importc: "PostMessageA".}

-  proc PostThreadMessage*(idThread: DWORD, Msg: UINT, wp: WPARAM,

+  proc PostThreadMessage*(idThread: DWORD, Msg: WINUINT, wp: WPARAM,

                           lp: LPARAM): WINBOOL{.stdcall, dynlib: "user32",

       importc: "PostThreadMessageA".}

-  proc DefWindowProc*(wnd: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM): LRESULT{.

+  proc DefWindowProc*(wnd: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM): LRESULT{.

       stdcall, dynlib: "user32", importc: "DefWindowProcA".}

-  proc CallWindowProc*(lpPrevWndFunc: WNDPROC, wnd: HWND, Msg: UINT,

+  proc CallWindowProc*(lpPrevWndFunc: WNDPROC, wnd: HWND, Msg: WINUINT,

                        wp: WPARAM, lp: LPARAM): LRESULT{.stdcall,

       dynlib: "user32", importc: "CallWindowProcA".}

   proc RegisterClass*(lpWndClass: LPWNDCLASS): ATOM{.stdcall, dynlib: "user32",

@@ -17791,18 +17791,18 @@ else:
   proc SetDlgItemText*(hDlg: HWND, nIDDlgItem: int32, lpString: LPCSTR): WINBOOL{.

       stdcall, dynlib: "user32", importc: "SetDlgItemTextA".}

   proc GetDlgItemText*(hDlg: HWND, nIDDlgItem: int32, lpString: LPSTR,

-                       nMaxCount: int32): UINT{.stdcall, dynlib: "user32",

+                       nMaxCount: int32): WINUINT{.stdcall, dynlib: "user32",

       importc: "GetDlgItemTextA".}

-  proc SendDlgItemMessage*(hDlg: HWND, nIDDlgItem: int32, Msg: UINT,

+  proc SendDlgItemMessage*(hDlg: HWND, nIDDlgItem: int32, Msg: WINUINT,

                            wp: WPARAM, lp: LPARAM): LONG{.stdcall,

       dynlib: "user32", importc: "SendDlgItemMessageA".}

-  proc DefDlgProc*(hDlg: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM): LRESULT{.

+  proc DefDlgProc*(hDlg: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM): LRESULT{.

       stdcall, dynlib: "user32", importc: "DefDlgProcA".}

   proc CallMsgFilter*(lpMsg: LPMSG, nCode: int32): WINBOOL{.stdcall,

       dynlib: "user32", importc: "CallMsgFilterA".}

-  proc RegisterClipboardFormat*(lpszFormat: LPCSTR): UINT{.stdcall,

+  proc RegisterClipboardFormat*(lpszFormat: LPCSTR): WINUINT{.stdcall,

       dynlib: "user32", importc: "RegisterClipboardFormatA".}

-  proc GetClipboardFormatName*(format: UINT, lpszFormatName: LPSTR,

+  proc GetClipboardFormatName*(format: WINUINT, lpszFormatName: LPSTR,

                                cchMaxCount: int32): int32{.stdcall,

       dynlib: "user32", importc: "GetClipboardFormatNameA".}

   proc CharToOem*(lpszSrc: LPCSTR, lpszDst: LPSTR): WINBOOL{.stdcall,

@@ -17839,9 +17839,9 @@ else:
                                     importc: "VkKeyScanA".}

   proc VkKeyScanEx*(ch: CHAR, dwhkl: HKL): SHORT{.stdcall, dynlib: "user32",

       importc: "VkKeyScanExA".}

-  proc MapVirtualKey*(uCode: UINT, uMapType: UINT): UINT{.stdcall,

+  proc MapVirtualKey*(uCode: WINUINT, uMapType: WINUINT): WINUINT{.stdcall,

       dynlib: "user32", importc: "MapVirtualKeyA".}

-  proc MapVirtualKeyEx*(uCode: UINT, uMapType: UINT, dwhkl: HKL): UINT{.stdcall,

+  proc MapVirtualKeyEx*(uCode: WINUINT, uMapType: WINUINT, dwhkl: HKL): WINUINT{.stdcall,

       dynlib: "user32", importc: "MapVirtualKeyExA".}

   proc LoadAccelerators*(hInstance: HINST, lpTableName: LPCSTR): HACCEL{.

       stdcall, dynlib: "user32", importc: "LoadAcceleratorsA".}

@@ -17856,35 +17856,35 @@ else:
       dynlib: "user32", importc: "LoadMenuA".}

   proc LoadMenuIndirect*(lpMenuTemplate: LPMENUTEMPLATE): HMENU{.stdcall,

       dynlib: "user32", importc: "LoadMenuIndirectA".}

-  proc ChangeMenu*(menu: HMENU, cmd: UINT, lpszNewItem: LPCSTR,

-                   cmdInsert: UINT, flags: UINT): WINBOOL{.stdcall,

+  proc ChangeMenu*(menu: HMENU, cmd: WINUINT, lpszNewItem: LPCSTR,

+                   cmdInsert: WINUINT, flags: WINUINT): WINBOOL{.stdcall,

       dynlib: "user32", importc: "ChangeMenuA".}

-  proc GetMenuString*(menu: HMENU, uIDItem: UINT, lpString: LPSTR,

-                      nMaxCount: int32, uFlag: UINT): int32{.stdcall,

+  proc GetMenuString*(menu: HMENU, uIDItem: WINUINT, lpString: LPSTR,

+                      nMaxCount: int32, uFlag: WINUINT): int32{.stdcall,

       dynlib: "user32", importc: "GetMenuStringA".}

-  proc InsertMenu*(menu: HMENU, uPosition: UINT, uFlags: UINT,

-                   uIDNewItem: UINT, lpNewItem: LPCSTR): WINBOOL{.stdcall,

+  proc InsertMenu*(menu: HMENU, uPosition: WINUINT, uFlags: WINUINT,

+                   uIDNewItem: WINUINT, lpNewItem: LPCSTR): WINBOOL{.stdcall,

       dynlib: "user32", importc: "InsertMenuA".}

-  proc AppendMenu*(menu: HMENU, uFlags: UINT, uIDNewItem: UINT,

+  proc AppendMenu*(menu: HMENU, uFlags: WINUINT, uIDNewItem: WINUINT,

                    lpNewItem: LPCSTR): WINBOOL{.stdcall, dynlib: "user32",

       importc: "AppendMenuA".}

-  proc ModifyMenu*(hMnu: HMENU, uPosition: UINT, uFlags: UINT, uIDNewItem: UINT,

+  proc ModifyMenu*(hMnu: HMENU, uPosition: WINUINT, uFlags: WINUINT, uIDNewItem: WINUINT,

                    lpNewItem: LPCSTR): WINBOOL{.stdcall, dynlib: "user32",

       importc: "ModifyMenuA".}

-  proc InsertMenuItem*(para1: HMENU, para2: UINT, para3: WINBOOL,

+  proc InsertMenuItem*(para1: HMENU, para2: WINUINT, para3: WINBOOL,

                        para4: LPCMENUITEMINFO): WINBOOL{.stdcall,

       dynlib: "user32", importc: "InsertMenuItemA".}

-  proc GetMenuItemInfo*(para1: HMENU, para2: UINT, para3: WINBOOL,

+  proc GetMenuItemInfo*(para1: HMENU, para2: WINUINT, para3: WINBOOL,

                         para4: LPMENUITEMINFO): WINBOOL{.stdcall,

       dynlib: "user32", importc: "GetMenuItemInfoA".}

-  proc SetMenuItemInfo*(para1: HMENU, para2: UINT, para3: WINBOOL,

+  proc SetMenuItemInfo*(para1: HMENU, para2: WINUINT, para3: WINBOOL,

                         para4: LPCMENUITEMINFO): WINBOOL{.stdcall,

       dynlib: "user32", importc: "SetMenuItemInfoA".}

   proc DrawText*(hDC: HDC, lpString: LPCSTR, nCount: int32, lpRect: LPRECT,

-                 uFormat: UINT): int32{.stdcall, dynlib: "user32",

+                 uFormat: WINUINT): int32{.stdcall, dynlib: "user32",

                                         importc: "DrawTextA".}

   proc DrawTextEx*(para1: HDC, para2: LPSTR, para3: int32, para4: LPRECT,

-                   para5: UINT, para6: LPDRAWTEXTPARAMS): int32{.stdcall,

+                   para5: WINUINT, para6: LPDRAWTEXTPARAMS): int32{.stdcall,

       dynlib: "user32", importc: "DrawTextExA".}

   proc GrayString*(hDC: HDC, hBrush: HBRUSH, lpOutputFunc: GRAYSTRINGPROC,

                    lpData: LPARAM, nCount: int32, X: int32, Y: int32,

@@ -17892,7 +17892,7 @@ else:
       dynlib: "user32", importc: "GrayStringA".}

   proc DrawState*(para1: HDC, para2: HBRUSH, para3: DRAWSTATEPROC,

                   para4: LPARAM, para5: WPARAM, para6: int32, para7: int32,

-                  para8: int32, para9: int32, para10: UINT): WINBOOL{.stdcall,

+                  para8: int32, para9: int32, para10: WINUINT): WINBOOL{.stdcall,

       dynlib: "user32", importc: "DrawStateA".}

   proc TabbedTextOut*(dc: HDC, X: int32, Y: int32, lpString: LPCSTR,

                       nCount: int32, nTabPositions: int32,

@@ -17917,9 +17917,9 @@ else:
       stdcall, dynlib: "user32", importc: "GetWindowTextA".}

   proc GetWindowTextLength*(wnd: HWND): int32{.stdcall, dynlib: "user32",

       importc: "GetWindowTextLengthA".}

-  proc MessageBox*(wnd: HWND, lpText: LPCSTR, lpCaption: LPCSTR, uType: UINT): int32{.

+  proc MessageBox*(wnd: HWND, lpText: LPCSTR, lpCaption: LPCSTR, uType: WINUINT): int32{.

       stdcall, dynlib: "user32", importc: "MessageBoxA".}

-  proc MessageBoxEx*(wnd: HWND, lpText: LPCSTR, lpCaption: LPCSTR, uType: UINT,

+  proc MessageBoxEx*(wnd: HWND, lpText: LPCSTR, lpCaption: LPCSTR, uType: WINUINT,

                      wLanguageId: int16): int32{.stdcall, dynlib: "user32",

       importc: "MessageBoxExA".}

   proc MessageBoxIndirect*(para1: LPMSGBOXPARAMS): int32{.stdcall,

@@ -17967,44 +17967,44 @@ else:
       dynlib: "user32", importc: "LoadCursorFromFileA".}

   proc LoadIcon*(hInstance: HINST, lpIconName: LPCSTR): HICON{.stdcall,

       dynlib: "user32", importc: "LoadIconA".}

-  proc LoadImage*(para1: HINST, para2: LPCSTR, para3: UINT, para4: int32,

-                  para5: int32, para6: UINT): HANDLE{.stdcall, dynlib: "user32",

+  proc LoadImage*(para1: HINST, para2: LPCSTR, para3: WINUINT, para4: int32,

+                  para5: int32, para6: WINUINT): HANDLE{.stdcall, dynlib: "user32",

       importc: "LoadImageA".}

-  proc LoadString*(hInstance: HINST, uID: UINT, lpBuffer: LPSTR,

+  proc LoadString*(hInstance: HINST, uID: WINUINT, lpBuffer: LPSTR,

                    nBufferMax: int32): int32{.stdcall, dynlib: "user32",

       importc: "LoadStringA".}

   proc IsDialogMessage*(hDlg: HWND, lpMsg: LPMSG): WINBOOL{.stdcall,

       dynlib: "user32", importc: "IsDialogMessageA".}

   proc DlgDirList*(hDlg: HWND, lpPathSpec: LPSTR, nIDListBox: int32,

-                   nIDStaticPath: int32, uFileType: UINT): int32{.stdcall,

+                   nIDStaticPath: int32, uFileType: WINUINT): int32{.stdcall,

       dynlib: "user32", importc: "DlgDirListA".}

   proc DlgDirSelectEx*(hDlg: HWND, lpString: LPSTR, nCount: int32,

                        nIDListBox: int32): WINBOOL{.stdcall, dynlib: "user32",

       importc: "DlgDirSelectExA".}

   proc DlgDirListComboBox*(hDlg: HWND, lpPathSpec: LPSTR, nIDComboBox: int32,

-                           nIDStaticPath: int32, uFiletype: UINT): int32{.

+                           nIDStaticPath: int32, uFiletype: WINUINT): int32{.

       stdcall, dynlib: "user32", importc: "DlgDirListComboBoxA".}

   proc DlgDirSelectComboBoxEx*(hDlg: HWND, lpString: LPSTR, nCount: int32,

                                nIDComboBox: int32): WINBOOL{.stdcall,

       dynlib: "user32", importc: "DlgDirSelectComboBoxExA".}

-  proc DefFrameProc*(wnd: HWND, hWndMDIClient: HWND, uMsg: UINT,

+  proc DefFrameProc*(wnd: HWND, hWndMDIClient: HWND, uMsg: WINUINT,

                      wp: WPARAM, lp: LPARAM): LRESULT{.stdcall,

       dynlib: "user32", importc: "DefFrameProcA".}

-  proc DefMDIChildProc*(wnd: HWND, uMsg: UINT, wp: WPARAM, lp: LPARAM): LRESULT{.

+  proc DefMDIChildProc*(wnd: HWND, uMsg: WINUINT, wp: WPARAM, lp: LPARAM): LRESULT{.

       stdcall, dynlib: "user32", importc: "DefMDIChildProcA".}

   proc CreateMDIWindow*(lpClassName: LPSTR, lpWindowName: LPSTR, dwStyle: DWORD,

                         X: int32, Y: int32, nWidth: int32, nHeight: int32,

                         hWndParent: HWND, hInstance: HINST, lp: LPARAM): HWND{.

       stdcall, dynlib: "user32", importc: "CreateMDIWindowA".}

-  proc WinHelp*(hWndMain: HWND, lpszHelp: LPCSTR, uCommand: UINT, dwData: DWORD): WINBOOL{.

+  proc WinHelp*(hWndMain: HWND, lpszHelp: LPCSTR, uCommand: WINUINT, dwData: DWORD): WINBOOL{.

       stdcall, dynlib: "user32", importc: "WinHelpA".}

   proc ChangeDisplaySettings*(lpDevMode: LPDEVMODE, dwFlags: DWORD): LONG{.

       stdcall, dynlib: "user32", importc: "ChangeDisplaySettingsA".}

   proc EnumDisplaySettings*(lpszDeviceName: LPCSTR, iModeNum: DWORD,

                             lpDevMode: LPDEVMODE): WINBOOL{.stdcall,

       dynlib: "user32", importc: "EnumDisplaySettingsA".}

-  proc SystemParametersInfo*(uiAction: UINT, uiParam: UINT, pvParam: PVOID,

-                             fWinIni: UINT): WINBOOL{.stdcall, dynlib: "user32",

+  proc SystemParametersInfo*(uiAction: WINUINT, uiParam: WINUINT, pvParam: PVOID,

+                             fWinIni: WINUINT): WINBOOL{.stdcall, dynlib: "user32",

       importc: "SystemParametersInfoA".}

   proc AddFontResource*(para1: LPCSTR): int32{.stdcall, dynlib: "gdi32",

       importc: "AddFontResourceA".}

@@ -18037,25 +18037,25 @@ else:
   proc EnumFonts*(para1: HDC, para2: LPCSTR, para3: ENUMFONTSPROC,

                   para4: pointer): int32{.stdcall, dynlib: "gdi32",

       importc: "EnumFontsA".}

-  proc GetCharWidth*(para1: HDC, para2: UINT, para3: UINT, para4: LPINT): WINBOOL{.

+  proc GetCharWidth*(para1: HDC, para2: WINUINT, para3: WINUINT, para4: LPINT): WINBOOL{.

       stdcall, dynlib: "gdi32", importc: "GetCharWidthA".}

-  proc GetCharWidth32*(para1: HDC, para2: UINT, para3: UINT, para4: LPINT): WINBOOL{.

+  proc GetCharWidth32*(para1: HDC, para2: WINUINT, para3: WINUINT, para4: LPINT): WINBOOL{.

       stdcall, dynlib: "gdi32", importc: "GetCharWidth32A".}

-  proc GetCharWidthFloat*(para1: HDC, para2: UINT, para3: UINT, para4: ptr float32): WINBOOL{.

+  proc GetCharWidthFloat*(para1: HDC, para2: WINUINT, para3: WINUINT, para4: ptr float32): WINBOOL{.

       stdcall, dynlib: "gdi32", importc: "GetCharWidthFloatA".}

-  proc GetCharABCWidths*(para1: HDC, para2: UINT, para3: UINT, para4: LPABC): WINBOOL{.

+  proc GetCharABCWidths*(para1: HDC, para2: WINUINT, para3: WINUINT, para4: LPABC): WINBOOL{.

       stdcall, dynlib: "gdi32", importc: "GetCharABCWidthsA".}

-  proc GetCharABCWidthsFloat*(para1: HDC, para2: UINT, para3: UINT,

+  proc GetCharABCWidthsFloat*(para1: HDC, para2: WINUINT, para3: WINUINT,

                               para4: LPABCFLOAT): WINBOOL{.stdcall,

       dynlib: "gdi32", importc: "GetCharABCWidthsFloatA".}

-  proc GetGlyphOutline*(para1: HDC, para2: UINT, para3: UINT,

+  proc GetGlyphOutline*(para1: HDC, para2: WINUINT, para3: WINUINT,

                         para4: LPGLYPHMETRICS, para5: DWORD, para6: LPVOID,

                         para7: PMAT2): DWORD{.stdcall, dynlib: "gdi32",

       importc: "GetGlyphOutlineA".}

   proc GetMetaFile*(para1: LPCSTR): HMETAFILE{.stdcall, dynlib: "gdi32",

       importc: "GetMetaFileA".}

-  proc GetOutlineTextMetrics*(para1: HDC, para2: UINT,

-                              para3: LPOUTLINETEXTMETRIC): UINT{.stdcall,

+  proc GetOutlineTextMetrics*(para1: HDC, para2: WINUINT,

+                              para3: LPOUTLINETEXTMETRIC): WINUINT{.stdcall,

       dynlib: "gdi32", importc: "GetOutlineTextMetricsA".}

   proc GetTextExtentPoint*(para1: HDC, para2: LPCSTR, para3: int32,

                            para4: LPSIZE): WINBOOL{.stdcall, dynlib: "gdi32",

@@ -18081,7 +18081,7 @@ else:
       importc: "CreateEnhMetaFileA".}

   proc GetEnhMetaFile*(para1: LPCSTR): HENHMETAFILE{.stdcall, dynlib: "gdi32",

       importc: "GetEnhMetaFileA".}

-  proc GetEnhMetaFileDescription*(para1: HENHMETAFILE, para2: UINT, para3: LPSTR): UINT{.

+  proc GetEnhMetaFileDescription*(para1: HENHMETAFILE, para2: WINUINT, para3: LPSTR): WINUINT{.

       stdcall, dynlib: "gdi32", importc: "GetEnhMetaFileDescriptionA".}

   proc GetTextMetrics*(para1: HDC, para2: LPTEXTMETRIC): WINBOOL{.stdcall,

       dynlib: "gdi32", importc: "GetTextMetricsA".}

@@ -18092,8 +18092,8 @@ else:
   proc TextOut*(para1: HDC, para2: int32, para3: int32, para4: LPCSTR,

                 para5: int32): WINBOOL{.stdcall, dynlib: "gdi32",

                                         importc: "TextOutA".}

-  proc ExtTextOut*(para1: HDC, para2: int32, para3: int32, para4: UINT,

-                   para5: LPRECT, para6: LPCSTR, para7: UINT, para8: LPINT): WINBOOL{.

+  proc ExtTextOut*(para1: HDC, para2: int32, para3: int32, para4: WINUINT,

+                   para5: LPRECT, para6: LPCSTR, para7: WINUINT, para8: LPINT): WINBOOL{.

       stdcall, dynlib: "gdi32", importc: "ExtTextOutA".}

   proc PolyTextOut*(para1: HDC, para2: PPOLYTEXT, para3: int32): WINBOOL{.

       stdcall, dynlib: "gdi32", importc: "PolyTextOutA".}

@@ -18110,19 +18110,19 @@ else:
       dynlib: "gdi32", importc: "GetICMProfileA".}

   proc SetICMProfile*(para1: HDC, para2: LPSTR): WINBOOL{.stdcall,

       dynlib: "gdi32", importc: "SetICMProfileA".}

-  proc UpdateICMRegKey*(para1: DWORD, para2: DWORD, para3: LPSTR, para4: UINT): WINBOOL{.

+  proc UpdateICMRegKey*(para1: DWORD, para2: DWORD, para3: LPSTR, para4: WINUINT): WINBOOL{.

       stdcall, dynlib: "gdi32", importc: "UpdateICMRegKeyA".}

   proc EnumICMProfiles*(para1: HDC, para2: ICMENUMPROC, para3: LPARAM): int32{.

       stdcall, dynlib: "gdi32", importc: "EnumICMProfilesA".}

   proc PropertySheet*(lppsph: LPCPROPSHEETHEADER): int32{.stdcall,

       dynlib: "comctl32", importc: "PropertySheetA".}

   proc ImageList_LoadImage*(hi: HINST, lpbmp: LPCSTR, cx: int32, cGrow: int32,

-                            crMask: COLORREF, uType: UINT, uFlags: UINT): HIMAGELIST{.

+                            crMask: COLORREF, uType: WINUINT, uFlags: WINUINT): HIMAGELIST{.

       stdcall, dynlib: "comctl32", importc: "ImageList_LoadImageA".}

   proc CreateStatusWindow*(style: LONG, lpszText: LPCSTR, hwndParent: HWND,

-                           wID: UINT): HWND{.stdcall, dynlib: "comctl32",

+                           wID: WINUINT): HWND{.stdcall, dynlib: "comctl32",

       importc: "CreateStatusWindowA".}

-  proc DrawStatusText*(hDC: HDC, lprc: LPRECT, pszText: LPCSTR, uFlags: UINT){.

+  proc DrawStatusText*(hDC: HDC, lprc: LPRECT, pszText: LPCSTR, uFlags: WINUINT){.

       stdcall, dynlib: "comctl32", importc: "DrawStatusTextA".}

   proc GetOpenFileName*(para1: LPOPENFILENAME): WINBOOL{.stdcall,

       dynlib: "comdlg32", importc: "GetOpenFileNameA".}

@@ -18477,7 +18477,7 @@ else:
   proc DdeCreateStringHandle*(para1: DWORD, para2: cstring, para3: int32): HSZ{.

       stdcall, dynlib: "user32", importc: "DdeCreateStringHandleA".}

   proc DdeInitialize*(para1: LPDWORD, para2: PFNCALLBACK, para3: DWORD,

-                      para4: DWORD): UINT{.stdcall, dynlib: "user32",

+                      para4: DWORD): WINUINT{.stdcall, dynlib: "user32",

       importc: "DdeInitializeA".}

   proc DdeQueryString*(para1: DWORD, para2: HSZ, para3: cstring, para4: DWORD,

                        para5: int32): DWORD{.stdcall, dynlib: "user32",

@@ -18519,7 +18519,7 @@ proc GlobalReAlloc*(hMem: HGLOBAL, dwBytes: DWORD, uFlags: INT): HGLOBAL{.
     stdcall, dynlib: "kernel32", importc: "GlobalReAlloc".}

 proc GlobalSize*(hMem: HGLOBAL): DWORD{.stdcall, dynlib: "kernel32",

                                         importc: "GlobalSize".}

-proc GlobalFlags*(hMem: HGLOBAL): UINT{.stdcall, dynlib: "kernel32",

+proc GlobalFlags*(hMem: HGLOBAL): WINUINT{.stdcall, dynlib: "kernel32",

                                         importc: "GlobalFlags".}

 proc GlobalLock*(hMem: HGLOBAL): LPVOID{.stdcall, dynlib: "kernel32",

     importc: "GlobalLock".}

@@ -18529,7 +18529,7 @@ proc GlobalUnlock*(hMem: HGLOBAL): WINBOOL{.stdcall, dynlib: "kernel32",
     importc: "GlobalUnlock".}

 proc GlobalFree*(hMem: HGLOBAL): HGLOBAL{.stdcall, dynlib: "kernel32",

     importc: "GlobalFree".}

-proc GlobalCompact*(dwMinFree: DWORD): UINT{.stdcall, dynlib: "kernel32",

+proc GlobalCompact*(dwMinFree: DWORD): WINUINT{.stdcall, dynlib: "kernel32",

     importc: "GlobalCompact".}

 proc GlobalFix*(hMem: HGLOBAL){.stdcall, dynlib: "kernel32",

                                 importc: "GlobalFix".}

@@ -18541,9 +18541,9 @@ proc GlobalUnWire*(hMem: HGLOBAL): WINBOOL{.stdcall, dynlib: "kernel32",
     importc: "GlobalUnWire".}

 proc GlobalMemoryStatus*(lpBuffer: LPMEMORYSTATUS){.stdcall, dynlib: "kernel32",

     importc: "GlobalMemoryStatus".}

-proc LocalAlloc*(uFlags: UINT, uBytes: UINT): HLOCAL{.stdcall,

+proc LocalAlloc*(uFlags: WINUINT, uBytes: WINUINT): HLOCAL{.stdcall,

     dynlib: "kernel32", importc: "LocalAlloc".}

-proc LocalReAlloc*(hMem: HLOCAL, uBytes: UINT, uFlags: UINT): HLOCAL{.stdcall,

+proc LocalReAlloc*(hMem: HLOCAL, uBytes: WINUINT, uFlags: WINUINT): HLOCAL{.stdcall,

     dynlib: "kernel32", importc: "LocalReAlloc".}

 proc LocalLock*(hMem: HLOCAL): LPVOID{.stdcall, dynlib: "kernel32",

                                        importc: "LocalLock".}

@@ -18551,15 +18551,15 @@ proc LocalHandle*(pMem: LPCVOID): HLOCAL{.stdcall, dynlib: "kernel32",
     importc: "LocalHandle".}

 proc LocalUnlock*(hMem: HLOCAL): WINBOOL{.stdcall, dynlib: "kernel32",

     importc: "LocalUnlock".}

-proc LocalSize*(hMem: HLOCAL): UINT{.stdcall, dynlib: "kernel32",

+proc LocalSize*(hMem: HLOCAL): WINUINT{.stdcall, dynlib: "kernel32",

                                      importc: "LocalSize".}

-proc LocalFlags*(hMem: HLOCAL): UINT{.stdcall, dynlib: "kernel32",

+proc LocalFlags*(hMem: HLOCAL): WINUINT{.stdcall, dynlib: "kernel32",

                                       importc: "LocalFlags".}

 proc LocalFree*(hMem: HLOCAL): HLOCAL{.stdcall, dynlib: "kernel32",

                                        importc: "LocalFree".}

-proc LocalShrink*(hMem: HLOCAL, cbNewSize: UINT): UINT{.stdcall,

+proc LocalShrink*(hMem: HLOCAL, cbNewSize: WINUINT): WINUINT{.stdcall,

     dynlib: "kernel32", importc: "LocalShrink".}

-proc LocalCompact*(uMinFree: UINT): UINT{.stdcall, dynlib: "kernel32",

+proc LocalCompact*(uMinFree: WINUINT): WINUINT{.stdcall, dynlib: "kernel32",

     importc: "LocalCompact".}

 proc FlushInstructionCache*(hProcess: HANDLE, lpBaseAddress: LPCVOID,

                             dwSize: DWORD): WINBOOL{.stdcall,

@@ -18595,7 +18595,7 @@ proc HeapSize*(hHeap: HANDLE, dwFlags: DWORD, lpMem: LPCVOID): DWORD{.stdcall,
     dynlib: "kernel32", importc: "HeapSize".}

 proc HeapValidate*(hHeap: HANDLE, dwFlags: DWORD, lpMem: LPCVOID): WINBOOL{.

     stdcall, dynlib: "kernel32", importc: "HeapValidate".}

-proc HeapCompact*(hHeap: HANDLE, dwFlags: DWORD): UINT{.stdcall,

+proc HeapCompact*(hHeap: HANDLE, dwFlags: DWORD): WINUINT{.stdcall,

     dynlib: "kernel32", importc: "HeapCompact".}

 proc GetProcessHeap*(): HANDLE{.stdcall, dynlib: "kernel32",

                                 importc: "GetProcessHeap".}

@@ -18628,9 +18628,9 @@ proc GetCurrentProcess*(): HANDLE{.stdcall, dynlib: "kernel32",
                                    importc: "GetCurrentProcess".}

 proc GetCurrentProcessId*(): DWORD{.stdcall, dynlib: "kernel32",

                                     importc: "GetCurrentProcessId".}

-proc ExitProcess*(uExitCode: UINT){.stdcall, dynlib: "kernel32",

+proc ExitProcess*(uExitCode: WINUINT){.stdcall, dynlib: "kernel32",

                                     importc: "ExitProcess".}

-proc TerminateProcess*(hProcess: HANDLE, uExitCode: UINT): WINBOOL{.stdcall,

+proc TerminateProcess*(hProcess: HANDLE, uExitCode: WINUINT): WINBOOL{.stdcall,

     dynlib: "kernel32", importc: "TerminateProcess".}

 proc SetProcessAffinityMask*(hProcess: THandle, dwProcessAffinityMask: DWORD): WINBOOL{.

     stdcall, dynlib: "kernel32", importc: "SetProcessAffinityMask".}

@@ -18681,7 +18681,7 @@ proc CreateIoCompletionPort*(FileHandle: HANDLE, ExistingCompletionPort: HANDLE,
                              CompletionKey: DWORD,

                              NumberOfConcurrentThreads: DWORD): HANDLE{.stdcall,

     dynlib: "kernel32", importc: "CreateIoCompletionPort".}

-proc SetErrorMode*(uMode: UINT): UINT{.stdcall, dynlib: "kernel32",

+proc SetErrorMode*(uMode: WINUINT): WINUINT{.stdcall, dynlib: "kernel32",

                                        importc: "SetErrorMode".}

 proc ReadProcessMemory*(hProcess: HANDLE, lpBaseAddress: LPCVOID,

                         lpBuffer: LPVOID, nSize: DWORD,

@@ -18741,7 +18741,7 @@ proc InitAtomTable*(nSize: DWORD): WINBOOL{.stdcall, dynlib: "kernel32",
     importc: "InitAtomTable".}

 proc DeleteAtom*(nAtom: ATOM): ATOM{.stdcall, dynlib: "kernel32",

                                      importc: "DeleteAtom".}

-proc SetHandleCount*(uNumber: UINT): UINT{.stdcall, dynlib: "kernel32",

+proc SetHandleCount*(uNumber: WINUINT): WINUINT{.stdcall, dynlib: "kernel32",

     importc: "SetHandleCount".}

 proc GetLogicalDrives*(): DWORD{.stdcall, dynlib: "kernel32",

                                  importc: "GetLogicalDrives".}

@@ -18803,7 +18803,7 @@ proc SetHandleInformation*(hObject: HANDLE, dwMask: DWORD, dwFlags: DWORD): WINB
     stdcall, dynlib: "kernel32", importc: "SetHandleInformation".}

 proc LoadModule*(lpModuleName: LPCSTR, lpParameterBlock: LPVOID): DWORD{.

     stdcall, dynlib: "kernel32", importc: "LoadModule".}

-proc WinExec*(lpCmdLine: LPCSTR, uCmdShow: UINT): UINT{.stdcall,

+proc WinExec*(lpCmdLine: LPCSTR, uCmdShow: WINUINT): WINUINT{.stdcall,

     dynlib: "kernel32", importc: "WinExec".}

 proc ClearCommBreak*(hFile: HANDLE): WINBOOL{.stdcall, dynlib: "kernel32",

     importc: "ClearCommBreak".}

@@ -18954,15 +18954,15 @@ proc FlushViewOfFile*(lpBaseAddress: LPCVOID, dwNumberOfBytesToFlush: DWORD): WI
     stdcall, dynlib: "kernel32", importc: "FlushViewOfFile".}

 proc UnmapViewOfFile*(lpBaseAddress: LPVOID): WINBOOL{.stdcall,

     dynlib: "kernel32", importc: "UnmapViewOfFile".}

-proc OpenFile*(lpFileName: LPCSTR, lpReOpenBuff: LPOFSTRUCT, uStyle: UINT): HFILE{.

+proc OpenFile*(lpFileName: LPCSTR, lpReOpenBuff: LPOFSTRUCT, uStyle: WINUINT): HFILE{.

     stdcall, dynlib: "kernel32", importc: "OpenFile".}

 proc lopen*(lpPathName: LPCSTR, iReadWrite: int32): HFILE{.stdcall,

     dynlib: "kernel32", importc: "_lopen".}

 proc lcreat*(lpPathName: LPCSTR, iAttribute: int32): HFILE{.stdcall,

     dynlib: "kernel32", importc: "_lcreat".}

-proc lread*(hFile: HFILE, lpBuffer: LPVOID, uBytes: UINT): UINT{.stdcall,

+proc lread*(hFile: HFILE, lpBuffer: LPVOID, uBytes: WINUINT): WINUINT{.stdcall,

     dynlib: "kernel32", importc: "_lread".}

-proc lwrite*(hFile: HFILE, lpBuffer: LPCSTR, uBytes: UINT): UINT{.stdcall,

+proc lwrite*(hFile: HFILE, lpBuffer: LPCSTR, uBytes: WINUINT): WINUINT{.stdcall,

     dynlib: "kernel32", importc: "_lwrite".}

 proc hread*(hFile: HFILE, lpBuffer: LPVOID, lBytes: int32): int32{.stdcall,

     dynlib: "kernel32", importc: "_hread".}

@@ -19233,13 +19233,13 @@ proc SetPriorityClass*(hProcess: HANDLE, dwPriorityClass: DWORD): WINBOOL{.
     stdcall, dynlib: "kernel32", importc: "SetPriorityClass".}

 proc GetPriorityClass*(hProcess: HANDLE): DWORD{.stdcall, dynlib: "kernel32",

     importc: "GetPriorityClass".}

-proc IsBadReadPtr*(lp: pointer, ucb: UINT): WINBOOL{.stdcall,

+proc IsBadReadPtr*(lp: pointer, ucb: WINUINT): WINBOOL{.stdcall,

     dynlib: "kernel32", importc: "IsBadReadPtr".}

-proc IsBadWritePtr*(lp: LPVOID, ucb: UINT): WINBOOL{.stdcall,

+proc IsBadWritePtr*(lp: LPVOID, ucb: WINUINT): WINBOOL{.stdcall,

     dynlib: "kernel32", importc: "IsBadWritePtr".}

-proc IsBadHugeReadPtr*(lp: pointer, ucb: UINT): WINBOOL{.stdcall,

+proc IsBadHugeReadPtr*(lp: pointer, ucb: WINUINT): WINBOOL{.stdcall,

     dynlib: "kernel32", importc: "IsBadHugeReadPtr".}

-proc IsBadHugeWritePtr*(lp: LPVOID, ucb: UINT): WINBOOL{.stdcall,

+proc IsBadHugeWritePtr*(lp: LPVOID, ucb: WINUINT): WINBOOL{.stdcall,

     dynlib: "kernel32", importc: "IsBadHugeWritePtr".}

 proc IsBadCodePtr*(lpfn: FARPROC): WINBOOL{.stdcall, dynlib: "kernel32",

     importc: "IsBadCodePtr".}

@@ -19249,7 +19249,7 @@ proc QueryPerformanceCounter*(lpPerformanceCount: PLARGE_INTEGER): WINBOOL{.
     stdcall, dynlib: "kernel32", importc: "QueryPerformanceCounter".}

 proc QueryPerformanceFrequency*(lpFrequency: PLARGE_INTEGER): WINBOOL{.stdcall,

     dynlib: "kernel32", importc: "QueryPerformanceFrequency".}

-proc ActivateKeyboardLayout*(hkl: HKL, Flags: UINT): WINBOOL{.stdcall,

+proc ActivateKeyboardLayout*(hkl: HKL, Flags: WINUINT): WINBOOL{.stdcall,

     dynlib: "user32", importc: "ActivateKeyboardLayout".}

 proc UnloadKeyboardLayout*(hkl: HKL): WINBOOL{.stdcall, dynlib: "user32",

     importc: "UnloadKeyboardLayout".}

@@ -19286,11 +19286,11 @@ proc TranslateMessage*(lpMsg: LPMSG): WINBOOL{.stdcall, dynlib: "user32",
     importc: "TranslateMessage".}

 proc SetMessageQueue*(cMessagesMax: int32): WINBOOL{.stdcall, dynlib: "user32",

     importc: "SetMessageQueue".}

-proc RegisterHotKey*(wnd: HWND, anID: int32, fsModifiers: UINT, vk: UINT): WINBOOL{.

+proc RegisterHotKey*(wnd: HWND, anID: int32, fsModifiers: WINUINT, vk: WINUINT): WINBOOL{.

     stdcall, dynlib: "user32", importc: "RegisterHotKey".}

 proc UnregisterHotKey*(wnd: HWND, anID: int32): WINBOOL{.stdcall,

     dynlib: "user32", importc: "UnregisterHotKey".}

-proc ExitWindowsEx*(uFlags: UINT, dwReserved: DWORD): WINBOOL{.stdcall,

+proc ExitWindowsEx*(uFlags: WINUINT, dwReserved: DWORD): WINBOOL{.stdcall,

     dynlib: "user32", importc: "ExitWindowsEx".}

 proc SwapMouseButton*(fSwap: WINBOOL): WINBOOL{.stdcall, dynlib: "user32",

     importc: "SwapMouseButton".}

@@ -19302,7 +19302,7 @@ proc GetMessageExtraInfo*(): LONG{.stdcall, dynlib: "user32",
                                    importc: "GetMessageExtraInfo".}

 proc SetMessageExtraInfo*(lp: LPARAM): LPARAM{.stdcall, dynlib: "user32",

     importc: "SetMessageExtraInfo".}

-proc BroadcastSystemMessage*(para1: DWORD, para2: LPDWORD, para3: UINT,

+proc BroadcastSystemMessage*(para1: DWORD, para2: LPDWORD, para3: WINUINT,

                              para4: WPARAM, para5: LPARAM): int32{.stdcall,

     dynlib: "user32", importc: "BroadcastSystemMessage".}

 proc AttachThreadInput*(idAttach: DWORD, idAttachTo: DWORD, fAttach: WINBOOL): WINBOOL{.

@@ -19316,9 +19316,9 @@ proc PostQuitMessage*(nExitCode: int32){.stdcall, dynlib: "user32",
     importc: "PostQuitMessage".}

 proc InSendMessage*(): WINBOOL{.stdcall, dynlib: "user32",

                                 importc: "InSendMessage".}

-proc GetDoubleClickTime*(): UINT{.stdcall, dynlib: "user32",

+proc GetDoubleClickTime*(): WINUINT{.stdcall, dynlib: "user32",

                                   importc: "GetDoubleClickTime".}

-proc SetDoubleClickTime*(para1: UINT): WINBOOL{.stdcall, dynlib: "user32",

+proc SetDoubleClickTime*(para1: WINUINT): WINBOOL{.stdcall, dynlib: "user32",

     importc: "SetDoubleClickTime".}

 proc IsWindow*(wnd: HWND): WINBOOL{.stdcall, dynlib: "user32",

                                      importc: "IsWindow".}

@@ -19344,7 +19344,7 @@ proc MoveWindow*(wnd: HWND, X: int32, Y: int32, nWidth: int32, nHeight: int32,
                  bRepaint: WINBOOL): WINBOOL{.stdcall, dynlib: "user32",

     importc: "MoveWindow".}

 proc SetWindowPos*(wnd: HWND, hWndInsertAfter: HWND, X: int32, Y: int32,

-                   cx: int32, cy: int32, uFlags: UINT): WINBOOL{.stdcall,

+                   cx: int32, cy: int32, uFlags: WINUINT): WINBOOL{.stdcall,

     dynlib: "user32", importc: "SetWindowPos".}

 proc GetWindowPlacement*(wnd: HWND, lpwndpl: var WINDOWPLACEMENT): WINBOOL{.

     stdcall, dynlib: "user32", importc: "GetWindowPlacement".}

@@ -19357,7 +19357,7 @@ proc SetWindowPlacement*(wnd: HWND, lpwndpl: PWINDOWPLACEMENT): WINBOOL{.
 proc BeginDeferWindowPos*(nNumWindows: int32): HDWP{.stdcall, dynlib: "user32",

     importc: "BeginDeferWindowPos".}

 proc DeferWindowPos*(hWinPosInfo: HDWP, wnd: HWND, hWndInsertAfter: HWND,

-                     x: int32, y: int32, cx: int32, cy: int32, uFlags: UINT): HDWP{.

+                     x: int32, y: int32, cx: int32, cy: int32, uFlags: WINUINT): HDWP{.

     stdcall, dynlib: "user32", importc: "DeferWindowPos".}

 proc EndDeferWindowPos*(hWinPosInfo: HDWP): WINBOOL{.stdcall, dynlib: "user32",

     importc: "EndDeferWindowPos".}

@@ -19374,18 +19374,18 @@ proc EndDialog*(hDlg: HWND, nResult: int32): WINBOOL{.stdcall, dynlib: "user32",
     importc: "EndDialog".}

 proc GetDlgItem*(hDlg: HWND, nIDDlgItem: int32): HWND{.stdcall,

     dynlib: "user32", importc: "GetDlgItem".}

-proc SetDlgItemInt*(hDlg: HWND, nIDDlgItem: int32, uValue: UINT,

+proc SetDlgItemInt*(hDlg: HWND, nIDDlgItem: int32, uValue: WINUINT,

                     bSigned: WINBOOL): WINBOOL{.stdcall, dynlib: "user32",

     importc: "SetDlgItemInt".}

 proc GetDlgItemInt*(hDlg: HWND, nIDDlgItem: int32, lpTranslated: var WINBOOL,

-                    bSigned: WINBOOL): UINT{.stdcall, dynlib: "user32",

+                    bSigned: WINBOOL): WINUINT{.stdcall, dynlib: "user32",

     importc: "GetDlgItemInt".}

-proc CheckDlgButton*(hDlg: HWND, nIDButton: int32, uCheck: UINT): WINBOOL{.

+proc CheckDlgButton*(hDlg: HWND, nIDButton: int32, uCheck: WINUINT): WINBOOL{.

     stdcall, dynlib: "user32", importc: "CheckDlgButton".}

 proc CheckRadioButton*(hDlg: HWND, nIDFirstButton: int32, nIDLastButton: int32,

                        nIDCheckButton: int32): WINBOOL{.stdcall,

     dynlib: "user32", importc: "CheckRadioButton".}

-proc IsDlgButtonChecked*(hDlg: HWND, nIDButton: int32): UINT{.stdcall,

+proc IsDlgButtonChecked*(hDlg: HWND, nIDButton: int32): WINUINT{.stdcall,

     dynlib: "user32", importc: "IsDlgButtonChecked".}

 proc GetNextDlgGroupItem*(hDlg: HWND, hCtl: HWND, bPrevious: WINBOOL): HWND{.

     stdcall, dynlib: "user32", importc: "GetNextDlgGroupItem".}

@@ -19407,19 +19407,19 @@ proc GetClipboardViewer*(): HWND{.stdcall, dynlib: "user32",
                                   importc: "GetClipboardViewer".}

 proc ChangeClipboardChain*(hWndRemove: HWND, hWndNewNext: HWND): WINBOOL{.

     stdcall, dynlib: "user32", importc: "ChangeClipboardChain".}

-proc SetClipboardData*(uFormat: UINT, hMem: HANDLE): HANDLE{.stdcall,

+proc SetClipboardData*(uFormat: WINUINT, hMem: HANDLE): HANDLE{.stdcall,

     dynlib: "user32", importc: "SetClipboardData".}

-proc GetClipboardData*(uFormat: UINT): HANDLE{.stdcall, dynlib: "user32",

+proc GetClipboardData*(uFormat: WINUINT): HANDLE{.stdcall, dynlib: "user32",

     importc: "GetClipboardData".}

 proc CountClipboardFormats*(): int32{.stdcall, dynlib: "user32",

                                       importc: "CountClipboardFormats".}

-proc EnumClipboardFormats*(format: UINT): UINT{.stdcall, dynlib: "user32",

+proc EnumClipboardFormats*(format: WINUINT): WINUINT{.stdcall, dynlib: "user32",

     importc: "EnumClipboardFormats".}

 proc EmptyClipboard*(): WINBOOL{.stdcall, dynlib: "user32",

                                  importc: "EmptyClipboard".}

-proc IsClipboardFormatAvailable*(format: UINT): WINBOOL{.stdcall,

+proc IsClipboardFormatAvailable*(format: WINUINT): WINBOOL{.stdcall,

     dynlib: "user32", importc: "IsClipboardFormatAvailable".}

-proc GetPriorityClipboardFormat*(paFormatPriorityList: var UINT, cFormats: int32): int32{.

+proc GetPriorityClipboardFormat*(paFormatPriorityList: var WINUINT, cFormats: int32): int32{.

     stdcall, dynlib: "user32", importc: "GetPriorityClipboardFormat".}

 proc GetOpenClipboardWindow*(): HWND{.stdcall, dynlib: "user32",

                                       importc: "GetOpenClipboardWindow".}

@@ -19432,7 +19432,7 @@ proc SetFocus*(wnd: HWND): HWND{.stdcall, dynlib: "user32", importc: "SetFocus".
 proc GetActiveWindow*(): HWND{.stdcall, dynlib: "user32",

                                importc: "GetActiveWindow".}

 proc GetFocus*(): HWND{.stdcall, dynlib: "user32", importc: "GetFocus".}

-proc GetKBCodePage*(): UINT{.stdcall, dynlib: "user32", importc: "GetKBCodePage".}

+proc GetKBCodePage*(): WINUINT{.stdcall, dynlib: "user32", importc: "GetKBCodePage".}

 proc GetKeyState*(nVirtKey: int32): SHORT{.stdcall, dynlib: "user32",

     importc: "GetKeyState".}

 proc GetAsyncKeyState*(vKey: int32): SHORT{.stdcall, dynlib: "user32",

@@ -19443,14 +19443,14 @@ proc SetKeyboardState*(lpKeyState: LPBYTE): WINBOOL{.stdcall, dynlib: "user32",
     importc: "SetKeyboardState".}

 proc GetKeyboardType*(nTypeFlag: int32): int32{.stdcall, dynlib: "user32",

     importc: "GetKeyboardType".}

-proc ToAscii*(uVirtKey: UINT, uScanCode: UINT, lpKeyState: PBYTE,

-              lpChar: LPWORD, uFlags: UINT): int32{.stdcall, dynlib: "user32",

+proc ToAscii*(uVirtKey: WINUINT, uScanCode: WINUINT, lpKeyState: PBYTE,

+              lpChar: LPWORD, uFlags: WINUINT): int32{.stdcall, dynlib: "user32",

     importc: "ToAscii".}

-proc ToAsciiEx*(uVirtKey: UINT, uScanCode: UINT, lpKeyState: PBYTE,

-                lpChar: LPWORD, uFlags: UINT, dwhkl: HKL): int32{.stdcall,

+proc ToAsciiEx*(uVirtKey: WINUINT, uScanCode: WINUINT, lpKeyState: PBYTE,

+                lpChar: LPWORD, uFlags: WINUINT, dwhkl: HKL): int32{.stdcall,

     dynlib: "user32", importc: "ToAsciiEx".}

-proc ToUnicode*(wVirtKey: UINT, wScanCode: UINT, lpKeyState: PBYTE,

-                pwszBuff: LPWSTR, cchBuff: int32, wFlags: UINT): int32{.stdcall,

+proc ToUnicode*(wVirtKey: WINUINT, wScanCode: WINUINT, lpKeyState: PBYTE,

+                pwszBuff: LPWSTR, cchBuff: int32, wFlags: WINUINT): int32{.stdcall,

     dynlib: "user32", importc: "ToUnicode".}

 proc OemKeyScan*(wOemChar: int16): DWORD{.stdcall, dynlib: "user32",

     importc: "OemKeyScan".}

@@ -19461,7 +19461,7 @@ proc mouse_event*(dwFlags: DWORD, dx: DWORD, dy: DWORD, cButtons: DWORD,
                                        importc: "mouse_event".}

 proc GetInputState*(): WINBOOL{.stdcall, dynlib: "user32",

                                 importc: "GetInputState".}

-proc GetQueueStatus*(flags: UINT): DWORD{.stdcall, dynlib: "user32",

+proc GetQueueStatus*(flags: WINUINT): DWORD{.stdcall, dynlib: "user32",

     importc: "GetQueueStatus".}

 proc GetCapture*(): HWND{.stdcall, dynlib: "user32", importc: "GetCapture".}

 proc SetCapture*(wnd: HWND): HWND{.stdcall, dynlib: "user32",

@@ -19472,9 +19472,9 @@ proc MsgWaitForMultipleObjects*(nCount: DWORD, pHandles: LPHANDLE,
                                 fWaitAll: WINBOOL, dwMilliseconds: DWORD,

                                 dwWakeMask: DWORD): DWORD{.stdcall,

     dynlib: "user32", importc: "MsgWaitForMultipleObjects".}

-proc SetTimer*(wnd: HWND, nIDEvent: UINT, uElapse: UINT, lpTimerFunc: TIMERPROC): UINT{.

+proc SetTimer*(wnd: HWND, nIDEvent: WINUINT, uElapse: WINUINT, lpTimerFunc: TIMERPROC): WINUINT{.

     stdcall, dynlib: "user32", importc: "SetTimer".}

-proc KillTimer*(wnd: HWND, uIDEvent: UINT): WINBOOL{.stdcall, dynlib: "user32",

+proc KillTimer*(wnd: HWND, uIDEvent: WINUINT): WINBOOL{.stdcall, dynlib: "user32",

     importc: "KillTimer".}

 proc IsWindowUnicode*(wnd: HWND): WINBOOL{.stdcall, dynlib: "user32",

     importc: "IsWindowUnicode".}

@@ -19489,10 +19489,10 @@ proc GetSystemMetrics*(nIndex: int32): int32{.stdcall, dynlib: "user32",
 proc GetMenu*(wnd: HWND): HMENU{.stdcall, dynlib: "user32", importc: "GetMenu".}

 proc SetMenu*(wnd: HWND, menu: HMENU): WINBOOL{.stdcall, dynlib: "user32",

     importc: "SetMenu".}

-proc HiliteMenuItem*(wnd: HWND, menu: HMENU, uIDHiliteItem: UINT,

-                     uHilite: UINT): WINBOOL{.stdcall, dynlib: "user32",

+proc HiliteMenuItem*(wnd: HWND, menu: HMENU, uIDHiliteItem: WINUINT,

+                     uHilite: WINUINT): WINBOOL{.stdcall, dynlib: "user32",

     importc: "HiliteMenuItem".}

-proc GetMenuState*(menu: HMENU, uId: UINT, uFlags: UINT): UINT{.stdcall,

+proc GetMenuState*(menu: HMENU, uId: WINUINT, uFlags: WINUINT): WINUINT{.stdcall,

     dynlib: "user32", importc: "GetMenuState".}

 proc DrawMenuBar*(wnd: HWND): WINBOOL{.stdcall, dynlib: "user32",

                                         importc: "DrawMenuBar".}

@@ -19503,37 +19503,37 @@ proc CreatePopupMenu*(): HMENU{.stdcall, dynlib: "user32",
                                 importc: "CreatePopupMenu".}

 proc DestroyMenu*(menu: HMENU): WINBOOL{.stdcall, dynlib: "user32",

     importc: "DestroyMenu".}

-proc CheckMenuItem*(menu: HMENU, uIDCheckItem: UINT, uCheck: UINT): DWORD{.

+proc CheckMenuItem*(menu: HMENU, uIDCheckItem: WINUINT, uCheck: WINUINT): DWORD{.

     stdcall, dynlib: "user32", importc: "CheckMenuItem".}

-proc EnableMenuItem*(menu: HMENU, uIDEnableItem: UINT, uEnable: UINT): WINBOOL{.

+proc EnableMenuItem*(menu: HMENU, uIDEnableItem: WINUINT, uEnable: WINUINT): WINBOOL{.

     stdcall, dynlib: "user32", importc: "EnableMenuItem".}

 proc GetSubMenu*(menu: HMENU, nPos: int32): HMENU{.stdcall, dynlib: "user32",

     importc: "GetSubMenu".}

-proc GetMenuItemID*(menu: HMENU, nPos: int32): UINT{.stdcall, dynlib: "user32",

+proc GetMenuItemID*(menu: HMENU, nPos: int32): WINUINT{.stdcall, dynlib: "user32",

     importc: "GetMenuItemID".}

 proc GetMenuItemCount*(menu: HMENU): int32{.stdcall, dynlib: "user32",

     importc: "GetMenuItemCount".}

-proc RemoveMenu*(menu: HMENU, uPosition: UINT, uFlags: UINT): WINBOOL{.stdcall,

+proc RemoveMenu*(menu: HMENU, uPosition: WINUINT, uFlags: WINUINT): WINBOOL{.stdcall,

     dynlib: "user32", importc: "RemoveMenu".}

-proc DeleteMenu*(menu: HMENU, uPosition: UINT, uFlags: UINT): WINBOOL{.stdcall,

+proc DeleteMenu*(menu: HMENU, uPosition: WINUINT, uFlags: WINUINT): WINBOOL{.stdcall,

     dynlib: "user32", importc: "DeleteMenu".}

-proc SetMenuItemBitmaps*(menu: HMENU, uPosition: UINT, uFlags: UINT,

+proc SetMenuItemBitmaps*(menu: HMENU, uPosition: WINUINT, uFlags: WINUINT,

                          hBitmapUnchecked: HBITMAP, hBitmapChecked: HBITMAP): WINBOOL{.

     stdcall, dynlib: "user32", importc: "SetMenuItemBitmaps".}

 proc GetMenuCheckMarkDimensions*(): LONG{.stdcall, dynlib: "user32",

     importc: "GetMenuCheckMarkDimensions".}

-proc TrackPopupMenu*(menu: HMENU, uFlags: UINT, x: int32, y: int32,

+proc TrackPopupMenu*(menu: HMENU, uFlags: WINUINT, x: int32, y: int32,

                      nReserved: int32, wnd: HWND, prcRect: var RECT): WINBOOL{.

     stdcall, dynlib: "user32", importc: "TrackPopupMenu".}

-proc GetMenuDefaultItem*(menu: HMENU, fByPos: UINT, gmdiFlags: UINT): UINT{.

+proc GetMenuDefaultItem*(menu: HMENU, fByPos: WINUINT, gmdiFlags: WINUINT): WINUINT{.

     stdcall, dynlib: "user32", importc: "GetMenuDefaultItem".}

-proc SetMenuDefaultItem*(menu: HMENU, uItem: UINT, fByPos: UINT): WINBOOL{.

+proc SetMenuDefaultItem*(menu: HMENU, uItem: WINUINT, fByPos: WINUINT): WINBOOL{.

     stdcall, dynlib: "user32", importc: "SetMenuDefaultItem".}

-proc GetMenuItemRect*(wnd: HWND, menu: HMENU, uItem: UINT, lprcItem: LPRECT): WINBOOL{.

+proc GetMenuItemRect*(wnd: HWND, menu: HMENU, uItem: WINUINT, lprcItem: LPRECT): WINBOOL{.

     stdcall, dynlib: "user32", importc: "GetMenuItemRect".}

 proc MenuItemFromPoint*(wnd: HWND, menu: HMENU, ptScreen: POINT): int32{.

     stdcall, dynlib: "user32", importc: "MenuItemFromPoint".}

-proc DragObject*(para1: HWND, para2: HWND, para3: UINT, para4: DWORD,

+proc DragObject*(para1: HWND, para2: HWND, para3: WINUINT, para4: DWORD,

                  para5: HCURSOR): DWORD{.stdcall, dynlib: "user32",

     importc: "DragObject".}

 proc DragDetect*(wnd: HWND, pt: POINT): WINBOOL{.stdcall, dynlib: "user32",

@@ -19586,9 +19586,9 @@ proc InvalidateRgn*(wnd: HWND, hRgn: HRGN, bErase: WINBOOL): WINBOOL{.stdcall,
 proc ValidateRgn*(wnd: HWND, hRgn: HRGN): WINBOOL{.stdcall, dynlib: "user32",

     importc: "ValidateRgn".}

 proc RedrawWindow*(wnd: HWND, lprcUpdate: var RECT, hrgnUpdate: HRGN,

-                   flags: UINT): WINBOOL{.stdcall, dynlib: "user32",

+                   flags: WINUINT): WINBOOL{.stdcall, dynlib: "user32",

     importc: "RedrawWindow".}

-proc RedrawWindow*(wnd: HWND, lprcUpdate: LPRECT, hrgnUpdate: HRGN, flags: UINT): WINBOOL{.

+proc RedrawWindow*(wnd: HWND, lprcUpdate: LPRECT, hrgnUpdate: HRGN, flags: WINUINT): WINBOOL{.

     stdcall, dynlib: "user32", importc: "RedrawWindow".}

 proc LockWindowUpdate*(hWndLock: HWND): WINBOOL{.stdcall, dynlib: "user32",

     importc: "LockWindowUpdate".}

@@ -19600,7 +19600,7 @@ proc ScrollDC*(hDC: HDC, dx: int32, dy: int32, lprcScroll: var RECT,
     stdcall, dynlib: "user32", importc: "ScrollDC".}

 proc ScrollWindowEx*(wnd: HWND, dx: int32, dy: int32, prcScroll: var RECT,

                      prcClip: var RECT, hrgnUpdate: HRGN, prcUpdate: LPRECT,

-                     flags: UINT): int32{.stdcall, dynlib: "user32",

+                     flags: WINUINT): int32{.stdcall, dynlib: "user32",

     importc: "ScrollWindowEx".}

 proc SetScrollPos*(wnd: HWND, nBar: int32, nPos: int32, bRedraw: WINBOOL): int32{.

     stdcall, dynlib: "user32", importc: "SetScrollPos".}

@@ -19613,7 +19613,7 @@ proc GetScrollRange*(wnd: HWND, nBar: int32, lpMinPos: LPINT, lpMaxPos: LPINT):
     stdcall, dynlib: "user32", importc: "GetScrollRange".}

 proc ShowScrollBar*(wnd: HWND, wBar: int32, bShow: WINBOOL): WINBOOL{.stdcall,

     dynlib: "user32", importc: "ShowScrollBar".}

-proc EnableScrollBar*(wnd: HWND, wSBflags: UINT, wArrows: UINT): WINBOOL{.

+proc EnableScrollBar*(wnd: HWND, wSBflags: WINUINT, wArrows: WINUINT): WINBOOL{.

     stdcall, dynlib: "user32", importc: "EnableScrollBar".}

 proc GetClientRect*(wnd: HWND, lpRect: LPRECT): WINBOOL{.stdcall,

     dynlib: "user32", importc: "GetClientRect".}

@@ -19632,7 +19632,7 @@ proc SetMenuContextHelpId*(para1: HMENU, para2: DWORD): WINBOOL{.stdcall,
     dynlib: "user32", importc: "SetMenuContextHelpId".}

 proc GetMenuContextHelpId*(para1: HMENU): DWORD{.stdcall, dynlib: "user32",

     importc: "GetMenuContextHelpId".}

-proc MessageBeep*(uType: UINT): WINBOOL{.stdcall, dynlib: "user32",

+proc MessageBeep*(uType: WINUINT): WINBOOL{.stdcall, dynlib: "user32",

     importc: "MessageBeep".}

 proc ShowCursor*(bShow: WINBOOL): int32{.stdcall, dynlib: "user32",

     importc: "ShowCursor".}

@@ -19649,9 +19649,9 @@ proc GetClipCursor*(lpRect: LPRECT): WINBOOL{.stdcall, dynlib: "user32",
 proc GetCursor*(): HCURSOR{.stdcall, dynlib: "user32", importc: "GetCursor".}

 proc CreateCaret*(wnd: HWND, hBitmap: HBITMAP, nWidth: int32, nHeight: int32): WINBOOL{.

     stdcall, dynlib: "user32", importc: "CreateCaret".}

-proc GetCaretBlinkTime*(): UINT{.stdcall, dynlib: "user32",

+proc GetCaretBlinkTime*(): WINUINT{.stdcall, dynlib: "user32",

                                  importc: "GetCaretBlinkTime".}

-proc SetCaretBlinkTime*(uMSeconds: UINT): WINBOOL{.stdcall, dynlib: "user32",

+proc SetCaretBlinkTime*(uMSeconds: WINUINT): WINBOOL{.stdcall, dynlib: "user32",

     importc: "SetCaretBlinkTime".}

 proc DestroyCaret*(): WINBOOL{.stdcall, dynlib: "user32",

                                importc: "DestroyCaret".}

@@ -19668,7 +19668,7 @@ proc ClientToScreen*(wnd: HWND, lpPoint: LPPOINT): WINBOOL{.stdcall,
 proc ScreenToClient*(wnd: HWND, lpPoint: LPPOINT): WINBOOL{.stdcall,

     dynlib: "user32", importc: "ScreenToClient".}

 proc MapWindowPoints*(hWndFrom: HWND, hWndTo: HWND, lpPoints: LPPOINT,

-                      cPoints: UINT): int32{.stdcall, dynlib: "user32",

+                      cPoints: WINUINT): int32{.stdcall, dynlib: "user32",

     importc: "MapWindowPoints".}

 proc WindowFromPoint*(Point: POINT): HWND{.stdcall, dynlib: "user32",

     importc: "WindowFromPoint".}

@@ -19683,7 +19683,7 @@ proc SetSysColors*(cElements: int32, lpaElements: var wINT,
     dynlib: "user32", importc: "SetSysColors".}

 proc DrawFocusRect*(hDC: HDC, lprc: var RECT): WINBOOL{.stdcall,

     dynlib: "user32", importc: "DrawFocusRect".}

-proc FillRect*(hDC: HDC, lprc: RECT, hbr: HBRUSH): int32{.stdcall,

+proc FillRect*(hDC: HDC, lprc: var RECT, hbr: HBRUSH): int32{.stdcall,

     dynlib: "user32", importc: "FillRect".}

 proc FrameRect*(hDC: HDC, lprc: var RECT, hbr: HBRUSH): int32{.stdcall,

     dynlib: "user32", importc: "FrameRect".}

@@ -19743,7 +19743,7 @@ proc GetWindowThreadProcessId*(wnd: HWND, lpdwProcessId: LPDWORD): DWORD{.
     stdcall, dynlib: "user32", importc: "GetWindowThreadProcessId".}

 proc GetLastActivePopup*(wnd: HWND): HWND{.stdcall, dynlib: "user32",

     importc: "GetLastActivePopup".}

-proc GetWindow*(wnd: HWND, uCmd: UINT): HWND{.stdcall, dynlib: "user32",

+proc GetWindow*(wnd: HWND, uCmd: WINUINT): HWND{.stdcall, dynlib: "user32",

     importc: "GetWindow".}

 proc UnhookWindowsHook*(nCode: int32, pfnFilterProc: HOOKPROC): WINBOOL{.

     stdcall, dynlib: "user32", importc: "UnhookWindowsHook".}

@@ -19751,8 +19751,8 @@ proc UnhookWindowsHookEx*(hhk: HHOOK): WINBOOL{.stdcall, dynlib: "user32",
     importc: "UnhookWindowsHookEx".}

 proc CallNextHookEx*(hhk: HHOOK, nCode: int32, wp: WPARAM, lp: LPARAM): LRESULT{.

     stdcall, dynlib: "user32", importc: "CallNextHookEx".}

-proc CheckMenuRadioItem*(para1: HMENU, para2: UINT, para3: UINT, para4: UINT,

-                         para5: UINT): WINBOOL{.stdcall, dynlib: "user32",

+proc CheckMenuRadioItem*(para1: HMENU, para2: WINUINT, para3: WINUINT, para4: WINUINT,

+                         para5: WINUINT): WINBOOL{.stdcall, dynlib: "user32",

     importc: "CheckMenuRadioItem".}

 proc CreateCursor*(hInst: HINST, xHotSpot: int32, yHotSpot: int32,

                    nWidth: int32, nHeight: int32, pvANDPlane: pointer,

@@ -19771,17 +19771,17 @@ proc LookupIconIdFromDirectory*(presbits: PBYTE, fIcon: WINBOOL): int32{.
     stdcall, dynlib: "user32", importc: "LookupIconIdFromDirectory".}

 proc LookupIconIdFromDirectoryEx*(presbits: PBYTE, fIcon: WINBOOL,

                                   cxDesired: int32, cyDesired: int32,

-                                  Flags: UINT): int32{.stdcall,

+                                  Flags: WINUINT): int32{.stdcall,

     dynlib: "user32", importc: "LookupIconIdFromDirectoryEx".}

 proc CreateIconFromResource*(presbits: PBYTE, dwResSize: DWORD, fIcon: WINBOOL,

                              dwVer: DWORD): HICON{.stdcall, dynlib: "user32",

     importc: "CreateIconFromResource".}

 proc CreateIconFromResourceEx*(presbits: PBYTE, dwResSize: DWORD,

                                fIcon: WINBOOL, dwVer: DWORD, cxDesired: int32,

-                               cyDesired: int32, Flags: UINT): HICON{.stdcall,

+                               cyDesired: int32, Flags: WINUINT): HICON{.stdcall,

     dynlib: "user32", importc: "CreateIconFromResourceEx".}

-proc CopyImage*(para1: HANDLE, para2: UINT, para3: int32, para4: int32,

-                para5: UINT): HICON{.stdcall, dynlib: "user32",

+proc CopyImage*(para1: HANDLE, para2: WINUINT, para3: int32, para4: int32,

+                para5: WINUINT): HICON{.stdcall, dynlib: "user32",

                                      importc: "CopyImage".}

 proc CreateIconIndirect*(piconinfo: PICONINFO): HICON{.stdcall,

     dynlib: "user32", importc: "CreateIconIndirect".}

@@ -19798,37 +19798,37 @@ proc GetScrollInfo*(para1: HWND, para2: int32, para3: LPSCROLLINFO): WINBOOL{.
     stdcall, dynlib: "user32", importc: "GetScrollInfo".}

 proc TranslateMDISysAccel*(hWndClient: HWND, lpMsg: LPMSG): WINBOOL{.stdcall,

     dynlib: "user32", importc: "TranslateMDISysAccel".}

-proc ArrangeIconicWindows*(wnd: HWND): UINT{.stdcall, dynlib: "user32",

+proc ArrangeIconicWindows*(wnd: HWND): WINUINT{.stdcall, dynlib: "user32",

     importc: "ArrangeIconicWindows".}

-proc TileWindows*(hwndParent: HWND, wHow: UINT, lpRect: var RECT, cKids: UINT,

+proc TileWindows*(hwndParent: HWND, wHow: WINUINT, lpRect: var RECT, cKids: WINUINT,

                   lpKids: var HWND): int16{.stdcall, dynlib: "user32",

     importc: "TileWindows".}

-proc CascadeWindows*(hwndParent: HWND, wHow: UINT, lpRect: var RECT,

-                     cKids: UINT, lpKids: var HWND): int16{.stdcall,

+proc CascadeWindows*(hwndParent: HWND, wHow: WINUINT, lpRect: var RECT,

+                     cKids: WINUINT, lpKids: var HWND): int16{.stdcall,

     dynlib: "user32", importc: "CascadeWindows".}

 proc SetLastErrorEx*(dwErrCode: DWORD, dwType: DWORD){.stdcall,

     dynlib: "user32", importc: "SetLastErrorEx".}

 proc SetDebugErrorLevel*(dwLevel: DWORD){.stdcall, dynlib: "user32",

     importc: "SetDebugErrorLevel".}

-proc DrawEdge*(hdc: HDC, qrc: LPRECT, edge: UINT, grfFlags: UINT): WINBOOL{.

+proc DrawEdge*(hdc: HDC, qrc: LPRECT, edge: WINUINT, grfFlags: WINUINT): WINBOOL{.

     stdcall, dynlib: "user32", importc: "DrawEdge".}

-proc DrawFrameControl*(para1: HDC, para2: LPRECT, para3: UINT, para4: UINT): WINBOOL{.

+proc DrawFrameControl*(para1: HDC, para2: LPRECT, para3: WINUINT, para4: WINUINT): WINBOOL{.

     stdcall, dynlib: "user32", importc: "DrawFrameControl".}

-proc DrawCaption*(para1: HWND, para2: HDC, para3: var RECT, para4: UINT): WINBOOL{.

+proc DrawCaption*(para1: HWND, para2: HDC, para3: var RECT, para4: WINUINT): WINBOOL{.

     stdcall, dynlib: "user32", importc: "DrawCaption".}

 proc DrawAnimatedRects*(wnd: HWND, idAni: int32, lprcFrom: var RECT,

                         lprcTo: var RECT): WINBOOL{.stdcall, dynlib: "user32",

     importc: "DrawAnimatedRects".}

-proc TrackPopupMenuEx*(para1: HMENU, para2: UINT, para3: int32, para4: int32,

+proc TrackPopupMenuEx*(para1: HMENU, para2: WINUINT, para3: int32, para4: int32,

                        para5: HWND, para6: LPTPMPARAMS): WINBOOL{.stdcall,

     dynlib: "user32", importc: "TrackPopupMenuEx".}

-proc ChildWindowFromPointEx*(para1: HWND, para2: POINT, para3: UINT): HWND{.

+proc ChildWindowFromPointEx*(para1: HWND, para2: POINT, para3: WINUINT): HWND{.

     stdcall, dynlib: "user32", importc: "ChildWindowFromPointEx".}

 proc DrawIconEx*(hdc: HDC, xLeft: int32, yTop: int32, icon: HICON,

-                 cxWidth: int32, cyWidth: int32, istepIfAniCur: UINT,

-                 hbrFlickerFreeDraw: HBRUSH, diFlags: UINT): WINBOOL{.stdcall,

+                 cxWidth: int32, cyWidth: int32, istepIfAniCur: WINUINT,

+                 hbrFlickerFreeDraw: HBRUSH, diFlags: WINUINT): WINBOOL{.stdcall,

     dynlib: "user32", importc: "DrawIconEx".}

-proc AnimatePalette*(para1: HPALETTE, para2: UINT, para3: UINT,

+proc AnimatePalette*(para1: HPALETTE, para2: WINUINT, para3: WINUINT,

                      para4: var PALETTEENTRY): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "AnimatePalette".}

 proc Arc*(para1: HDC, para2: int32, para3: int32, para4: int32, para5: int32,

@@ -19846,7 +19846,7 @@ proc CloseMetaFile*(para1: HDC): HMETAFILE{.stdcall, dynlib: "gdi32",
     importc: "CloseMetaFile".}

 proc CombineRgn*(para1: HRGN, para2: HRGN, para3: HRGN, para4: int32): int32{.

     stdcall, dynlib: "gdi32", importc: "CombineRgn".}

-proc CreateBitmap*(para1: int32, para2: int32, para3: UINT, para4: UINT,

+proc CreateBitmap*(para1: int32, para2: int32, para3: WINUINT, para4: WINUINT,

                    para5: pointer): HBITMAP{.stdcall, dynlib: "gdi32",

     importc: "CreateBitmap".}

 proc CreateBitmapIndirect*(para1: var BITMAP): HBITMAP{.stdcall,

@@ -19860,11 +19860,11 @@ proc CreateDiscardableBitmap*(para1: HDC, para2: int32, para3: int32): HBITMAP{.
 proc CreateCompatibleDC*(para1: HDC): HDC{.stdcall, dynlib: "gdi32",

     importc: "CreateCompatibleDC".}

 proc CreateDIBitmap*(para1: HDC, para2: var BITMAPINFOHEADER, para3: DWORD,

-                     para4: pointer, para5: var BITMAPINFO, para6: UINT): HBITMAP{.

+                     para4: pointer, para5: var BITMAPINFO, para6: WINUINT): HBITMAP{.

     stdcall, dynlib: "gdi32", importc: "CreateDIBitmap".}

-proc CreateDIBPatternBrush*(para1: HGLOBAL, para2: UINT): HBRUSH{.stdcall,

+proc CreateDIBPatternBrush*(para1: HGLOBAL, para2: WINUINT): HBRUSH{.stdcall,

     dynlib: "gdi32", importc: "CreateDIBPatternBrush".}

-proc CreateDIBPatternBrushPt*(para1: pointer, para2: UINT): HBRUSH{.stdcall,

+proc CreateDIBPatternBrushPt*(para1: pointer, para2: WINUINT): HBRUSH{.stdcall,

     dynlib: "gdi32", importc: "CreateDIBPatternBrushPt".}

 proc CreateEllipticRgn*(para1: int32, para2: int32, para3: int32, para4: int32): HRGN{.

     stdcall, dynlib: "gdi32", importc: "CreateEllipticRgn".}

@@ -19918,7 +19918,7 @@ proc ExcludeClipRect*(para1: HDC, para2: int32, para3: int32, para4: int32,
 proc ExtCreateRegion*(para1: var XFORM, para2: DWORD, para3: var RGNDATA): HRGN{.

     stdcall, dynlib: "gdi32", importc: "ExtCreateRegion".}

 proc ExtFloodFill*(para1: HDC, para2: int32, para3: int32, para4: COLORREF,

-                   para5: UINT): WINBOOL{.stdcall, dynlib: "gdi32",

+                   para5: WINUINT): WINBOOL{.stdcall, dynlib: "gdi32",

     importc: "ExtFloodFill".}

 proc FillRgn*(para1: HDC, para2: HRGN, para3: HBRUSH): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "FillRgn".}

@@ -19938,7 +19938,7 @@ proc GetBitmapBits*(para1: HBITMAP, para2: LONG, para3: LPVOID): LONG{.stdcall,
     dynlib: "gdi32", importc: "GetBitmapBits".}

 proc GetBitmapDimensionEx*(para1: HBITMAP, para2: LPSIZE): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "GetBitmapDimensionEx".}

-proc GetBoundsRect*(para1: HDC, para2: LPRECT, para3: UINT): UINT{.stdcall,

+proc GetBoundsRect*(para1: HDC, para2: LPRECT, para3: WINUINT): WINUINT{.stdcall,

     dynlib: "gdi32", importc: "GetBoundsRect".}

 proc GetBrushOrgEx*(para1: HDC, para2: LPPOINT): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "GetBrushOrgEx".}

@@ -19948,14 +19948,14 @@ proc GetClipRgn*(para1: HDC, para2: HRGN): int32{.stdcall, dynlib: "gdi32",
     importc: "GetClipRgn".}

 proc GetMetaRgn*(para1: HDC, para2: HRGN): int32{.stdcall, dynlib: "gdi32",

     importc: "GetMetaRgn".}

-proc GetCurrentObject*(para1: HDC, para2: UINT): HGDIOBJ{.stdcall,

+proc GetCurrentObject*(para1: HDC, para2: WINUINT): HGDIOBJ{.stdcall,

     dynlib: "gdi32", importc: "GetCurrentObject".}

 proc GetCurrentPositionEx*(para1: HDC, para2: LPPOINT): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "GetCurrentPositionEx".}

 proc GetDeviceCaps*(para1: HDC, para2: int32): int32{.stdcall, dynlib: "gdi32",

     importc: "GetDeviceCaps".}

-proc GetDIBits*(para1: HDC, para2: HBITMAP, para3: UINT, para4: UINT,

-                para5: LPVOID, para6: LPBITMAPINFO, para7: UINT): int32{.

+proc GetDIBits*(para1: HDC, para2: HBITMAP, para3: WINUINT, para4: WINUINT,

+                para5: LPVOID, para6: LPBITMAPINFO, para7: WINUINT): int32{.

     stdcall, dynlib: "gdi32", importc: "GetDIBits".}

 proc GetFontData*(para1: HDC, para2: DWORD, para3: DWORD, para4: LPVOID,

                   para5: DWORD): DWORD{.stdcall, dynlib: "gdi32",

@@ -19964,16 +19964,16 @@ proc GetGraphicsMode*(para1: HDC): int32{.stdcall, dynlib: "gdi32",
     importc: "GetGraphicsMode".}

 proc GetMapMode*(para1: HDC): int32{.stdcall, dynlib: "gdi32",

                                      importc: "GetMapMode".}

-proc GetMetaFileBitsEx*(para1: HMETAFILE, para2: UINT, para3: LPVOID): UINT{.

+proc GetMetaFileBitsEx*(para1: HMETAFILE, para2: WINUINT, para3: LPVOID): WINUINT{.

     stdcall, dynlib: "gdi32", importc: "GetMetaFileBitsEx".}

 proc GetNearestColor*(para1: HDC, para2: COLORREF): COLORREF{.stdcall,

     dynlib: "gdi32", importc: "GetNearestColor".}

-proc GetNearestPaletteIndex*(para1: HPALETTE, para2: COLORREF): UINT{.stdcall,

+proc GetNearestPaletteIndex*(para1: HPALETTE, para2: COLORREF): WINUINT{.stdcall,

     dynlib: "gdi32", importc: "GetNearestPaletteIndex".}

 proc GetObjectType*(h: HGDIOBJ): DWORD{.stdcall, dynlib: "gdi32",

                                         importc: "GetObjectType".}

-proc GetPaletteEntries*(para1: HPALETTE, para2: UINT, para3: UINT,

-                        para4: LPPALETTEENTRY): UINT{.stdcall, dynlib: "gdi32",

+proc GetPaletteEntries*(para1: HPALETTE, para2: WINUINT, para3: WINUINT,

+                        para4: LPPALETTEENTRY): WINUINT{.stdcall, dynlib: "gdi32",

     importc: "GetPaletteEntries".}

 proc GetPixel*(para1: HDC, para2: int32, para3: int32): COLORREF{.stdcall,

     dynlib: "gdi32", importc: "GetPixel".}

@@ -19981,7 +19981,7 @@ proc GetPixelFormat*(para1: HDC): int32{.stdcall, dynlib: "gdi32",
     importc: "GetPixelFormat".}

 proc GetPolyFillMode*(para1: HDC): int32{.stdcall, dynlib: "gdi32",

     importc: "GetPolyFillMode".}

-proc GetRasterizerCaps*(para1: LPRASTERIZER_STATUS, para2: UINT): WINBOOL{.

+proc GetRasterizerCaps*(para1: LPRASTERIZER_STATUS, para2: WINUINT): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "GetRasterizerCaps".}

 proc GetRegionData*(para1: HRGN, para2: DWORD, para3: LPRGNDATA): DWORD{.

     stdcall, dynlib: "gdi32", importc: "GetRegionData".}

@@ -19991,14 +19991,14 @@ proc GetStockObject*(para1: int32): HGDIOBJ{.stdcall, dynlib: "gdi32",
     importc: "GetStockObject".}

 proc GetStretchBltMode*(para1: HDC): int32{.stdcall, dynlib: "gdi32",

     importc: "GetStretchBltMode".}

-proc GetSystemPaletteEntries*(para1: HDC, para2: UINT, para3: UINT,

-                              para4: LPPALETTEENTRY): UINT{.stdcall,

+proc GetSystemPaletteEntries*(para1: HDC, para2: WINUINT, para3: WINUINT,

+                              para4: LPPALETTEENTRY): WINUINT{.stdcall,

     dynlib: "gdi32", importc: "GetSystemPaletteEntries".}

-proc GetSystemPaletteUse*(para1: HDC): UINT{.stdcall, dynlib: "gdi32",

+proc GetSystemPaletteUse*(para1: HDC): WINUINT{.stdcall, dynlib: "gdi32",

     importc: "GetSystemPaletteUse".}

 proc GetTextCharacterExtra*(para1: HDC): int32{.stdcall, dynlib: "gdi32",

     importc: "GetTextCharacterExtra".}

-proc GetTextAlign*(para1: HDC): UINT{.stdcall, dynlib: "gdi32",

+proc GetTextAlign*(para1: HDC): WINUINT{.stdcall, dynlib: "gdi32",

                                       importc: "GetTextAlign".}

 proc GetTextColor*(para1: HDC): COLORREF{.stdcall, dynlib: "gdi32",

     importc: "GetTextColor".}

@@ -20064,12 +20064,12 @@ proc Rectangle*(para1: HDC, para2: int32, para3: int32, para4: int32,
                                         importc: "Rectangle".}

 proc RestoreDC*(para1: HDC, para2: int32): WINBOOL{.stdcall, dynlib: "gdi32",

     importc: "RestoreDC".}

-proc RealizePalette*(para1: HDC): UINT{.stdcall, dynlib: "gdi32",

+proc RealizePalette*(para1: HDC): WINUINT{.stdcall, dynlib: "gdi32",

                                         importc: "RealizePalette".}

 proc RoundRect*(para1: HDC, para2: int32, para3: int32, para4: int32,

                 para5: int32, para6: int32, para7: int32): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "RoundRect".}

-proc ResizePalette*(para1: HPALETTE, para2: UINT): WINBOOL{.stdcall,

+proc ResizePalette*(para1: HPALETTE, para2: WINUINT): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "ResizePalette".}

 proc SaveDC*(para1: HDC): int32{.stdcall, dynlib: "gdi32", importc: "SaveDC".}

 proc SelectClipRgn*(para1: HDC, para2: HRGN): int32{.stdcall, dynlib: "gdi32",

@@ -20088,15 +20088,15 @@ proc SetBkMode*(para1: HDC, para2: int32): int32{.stdcall, dynlib: "gdi32",
     importc: "SetBkMode".}

 proc SetBitmapBits*(para1: HBITMAP, para2: DWORD, para3: pointer): LONG{.

     stdcall, dynlib: "gdi32", importc: "SetBitmapBits".}

-proc SetBoundsRect*(para1: HDC, para2: var RECT, para3: UINT): UINT{.stdcall,

+proc SetBoundsRect*(para1: HDC, para2: var RECT, para3: WINUINT): WINUINT{.stdcall,

     dynlib: "gdi32", importc: "SetBoundsRect".}

-proc SetDIBits*(para1: HDC, para2: HBITMAP, para3: UINT, para4: UINT,

-                para5: pointer, para6: PBITMAPINFO, para7: UINT): int32{.

+proc SetDIBits*(para1: HDC, para2: HBITMAP, para3: WINUINT, para4: WINUINT,

+                para5: pointer, para6: PBITMAPINFO, para7: WINUINT): int32{.

     stdcall, dynlib: "gdi32", importc: "SetDIBits".}

 proc SetDIBitsToDevice*(para1: HDC, para2: int32, para3: int32, para4: DWORD,

-                        para5: DWORD, para6: int32, para7: int32, para8: UINT,

-                        para9: UINT, para10: pointer, para11: var BITMAPINFO,

-                        para12: UINT): int32{.stdcall, dynlib: "gdi32",

+                        para5: DWORD, para6: int32, para7: int32, para8: WINUINT,

+                        para9: WINUINT, para10: pointer, para11: var BITMAPINFO,

+                        para12: WINUINT): int32{.stdcall, dynlib: "gdi32",

     importc: "SetDIBitsToDevice".}

 proc SetMapperFlags*(para1: HDC, para2: DWORD): DWORD{.stdcall, dynlib: "gdi32",

     importc: "SetMapperFlags".}

@@ -20104,10 +20104,10 @@ proc SetGraphicsMode*(hdc: HDC, iMode: int32): int32{.stdcall, dynlib: "gdi32",
     importc: "SetGraphicsMode".}

 proc SetMapMode*(para1: HDC, para2: int32): int32{.stdcall, dynlib: "gdi32",

     importc: "SetMapMode".}

-proc SetMetaFileBitsEx*(para1: UINT, para2: var int8): HMETAFILE{.stdcall,

+proc SetMetaFileBitsEx*(para1: WINUINT, para2: var int8): HMETAFILE{.stdcall,

     dynlib: "gdi32", importc: "SetMetaFileBitsEx".}

-proc SetPaletteEntries*(para1: HPALETTE, para2: UINT, para3: UINT,

-                        para4: var PALETTEENTRY): UINT{.stdcall,

+proc SetPaletteEntries*(para1: HPALETTE, para2: WINUINT, para3: WINUINT,

+                        para4: var PALETTEENTRY): WINUINT{.stdcall,

     dynlib: "gdi32", importc: "SetPaletteEntries".}

 proc SetPixel*(para1: HDC, para2: int32, para3: int32, para4: COLORREF): COLORREF{.

     stdcall, dynlib: "gdi32", importc: "SetPixel".}

@@ -20125,26 +20125,26 @@ proc SetRectRgn*(para1: HRGN, para2: int32, para3: int32, para4: int32,
 proc StretchDIBits*(para1: HDC, para2: int32, para3: int32, para4: int32,

                     para5: int32, para6: int32, para7: int32, para8: int32,

                     para9: int32, para10: pointer, para11: var BITMAPINFO,

-                    para12: UINT, para13: DWORD): int32{.stdcall,

+                    para12: WINUINT, para13: DWORD): int32{.stdcall,

     dynlib: "gdi32", importc: "StretchDIBits".}

 proc SetROP2*(para1: HDC, para2: int32): int32{.stdcall, dynlib: "gdi32",

     importc: "SetROP2".}

 proc SetStretchBltMode*(para1: HDC, para2: int32): int32{.stdcall,

     dynlib: "gdi32", importc: "SetStretchBltMode".}

-proc SetSystemPaletteUse*(para1: HDC, para2: UINT): UINT{.stdcall,

+proc SetSystemPaletteUse*(para1: HDC, para2: WINUINT): WINUINT{.stdcall,

     dynlib: "gdi32", importc: "SetSystemPaletteUse".}

 proc SetTextCharacterExtra*(para1: HDC, para2: int32): int32{.stdcall,

     dynlib: "gdi32", importc: "SetTextCharacterExtra".}

 proc SetTextColor*(para1: HDC, para2: COLORREF): COLORREF{.stdcall,

     dynlib: "gdi32", importc: "SetTextColor".}

-proc SetTextAlign*(para1: HDC, para2: UINT): UINT{.stdcall, dynlib: "gdi32",

+proc SetTextAlign*(para1: HDC, para2: WINUINT): WINUINT{.stdcall, dynlib: "gdi32",

     importc: "SetTextAlign".}

 proc SetTextJustification*(para1: HDC, para2: int32, para3: int32): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "SetTextJustification".}

 proc UpdateColors*(para1: HDC): WINBOOL{.stdcall, dynlib: "gdi32",

     importc: "UpdateColors".}

 proc PlayMetaFileRecord*(para1: HDC, para2: LPHANDLETABLE, para3: LPMETARECORD,

-                         para4: UINT): WINBOOL{.stdcall, dynlib: "gdi32",

+                         para4: WINUINT): WINBOOL{.stdcall, dynlib: "gdi32",

     importc: "PlayMetaFileRecord".}

 proc EnumMetaFile*(para1: HDC, para2: HMETAFILE, para3: ENUMMETAFILEPROC,

                    para4: LPARAM): WINBOOL{.stdcall, dynlib: "gdi32",

@@ -20156,28 +20156,28 @@ proc DeleteEnhMetaFile*(para1: HENHMETAFILE): WINBOOL{.stdcall, dynlib: "gdi32",
 proc EnumEnhMetaFile*(para1: HDC, para2: HENHMETAFILE, para3: ENHMETAFILEPROC,

                       para4: LPVOID, para5: var RECT): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "EnumEnhMetaFile".}

-proc GetEnhMetaFileHeader*(para1: HENHMETAFILE, para2: UINT,

-                           para3: LPENHMETAHEADER): UINT{.stdcall,

+proc GetEnhMetaFileHeader*(para1: HENHMETAFILE, para2: WINUINT,

+                           para3: LPENHMETAHEADER): WINUINT{.stdcall,

     dynlib: "gdi32", importc: "GetEnhMetaFileHeader".}

-proc GetEnhMetaFilePaletteEntries*(para1: HENHMETAFILE, para2: UINT,

-                                   para3: LPPALETTEENTRY): UINT{.stdcall,

+proc GetEnhMetaFilePaletteEntries*(para1: HENHMETAFILE, para2: WINUINT,

+                                   para3: LPPALETTEENTRY): WINUINT{.stdcall,

     dynlib: "gdi32", importc: "GetEnhMetaFilePaletteEntries".}

-proc GetEnhMetaFileBits*(para1: HENHMETAFILE, para2: UINT, para3: LPBYTE): UINT{.

+proc GetEnhMetaFileBits*(para1: HENHMETAFILE, para2: WINUINT, para3: LPBYTE): WINUINT{.

     stdcall, dynlib: "gdi32", importc: "GetEnhMetaFileBits".}

-proc GetWinMetaFileBits*(para1: HENHMETAFILE, para2: UINT, para3: LPBYTE,

-                         para4: wINT, para5: HDC): UINT{.stdcall,

+proc GetWinMetaFileBits*(para1: HENHMETAFILE, para2: WINUINT, para3: LPBYTE,

+                         para4: wINT, para5: HDC): WINUINT{.stdcall,

     dynlib: "gdi32", importc: "GetWinMetaFileBits".}

 proc PlayEnhMetaFile*(para1: HDC, para2: HENHMETAFILE, para3: RECT): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "PlayEnhMetaFile".}

 proc PlayEnhMetaFileRecord*(para1: HDC, para2: LPHANDLETABLE,

-                            para3: var TENHMETARECORD, para4: UINT): WINBOOL{.

+                            para3: var TENHMETARECORD, para4: WINUINT): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "PlayEnhMetaFileRecord".}

-proc SetEnhMetaFileBits*(para1: UINT, para2: var int8): HENHMETAFILE{.stdcall,

+proc SetEnhMetaFileBits*(para1: WINUINT, para2: var int8): HENHMETAFILE{.stdcall,

     dynlib: "gdi32", importc: "SetEnhMetaFileBits".}

-proc SetWinMetaFileBits*(para1: UINT, para2: var int8, para3: HDC,

+proc SetWinMetaFileBits*(para1: WINUINT, para2: var int8, para3: HDC,

                          para4: var METAFILEPICT): HENHMETAFILE{.stdcall,

     dynlib: "gdi32", importc: "SetWinMetaFileBits".}

-proc GdiComment*(para1: HDC, para2: UINT, para3: var int8): WINBOOL{.stdcall,

+proc GdiComment*(para1: HDC, para2: WINUINT, para3: var int8): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "GdiComment".}

 proc AngleArc*(para1: HDC, para2: int32, para3: int32, para4: DWORD,

                para5: float32, para6: float32): WINBOOL{.stdcall,

@@ -20192,12 +20192,12 @@ proc ModifyWorldTransform*(para1: HDC, para2: var XFORM, para3: DWORD): WINBOOL{
     stdcall, dynlib: "gdi32", importc: "ModifyWorldTransform".}

 proc CombineTransform*(para1: LPXFORM, para2: var XFORM, para3: var XFORM): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "CombineTransform".}

-proc CreateDIBSection*(para1: HDC, para2: var BITMAPINFO, para3: UINT,

+proc CreateDIBSection*(para1: HDC, para2: var BITMAPINFO, para3: WINUINT,

                        para4: var pointer, para5: HANDLE, para6: DWORD): HBITMAP{.

     stdcall, dynlib: "gdi32", importc: "CreateDIBSection".}

-proc GetDIBColorTable*(para1: HDC, para2: UINT, para3: UINT, para4: var RGBQUAD): UINT{.

+proc GetDIBColorTable*(para1: HDC, para2: WINUINT, para3: WINUINT, para4: var RGBQUAD): WINUINT{.

     stdcall, dynlib: "gdi32", importc: "GetDIBColorTable".}

-proc SetDIBColorTable*(para1: HDC, para2: UINT, para3: UINT, para4: var RGBQUAD): UINT{.

+proc SetDIBColorTable*(para1: HDC, para2: WINUINT, para3: WINUINT, para4: var RGBQUAD): WINUINT{.

     stdcall, dynlib: "gdi32", importc: "SetDIBColorTable".}

 proc SetColorAdjustment*(para1: HDC, para2: var COLORADJUSTMENT): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "SetColorAdjustment".}

@@ -20324,7 +20324,7 @@ proc DestroyPropertySheetPage*(hPSPage: HPROPSHEETPAGE): WINBOOL{.stdcall,
 proc InitCommonControls*(){.stdcall, dynlib: "comctl32",

                             importc: "InitCommonControls".}

 proc ImageList_AddIcon*(himl: HIMAGELIST, hicon: HICON): int32

-proc ImageList_Create*(cx: int32, cy: int32, flags: UINT, cInitial: int32,

+proc ImageList_Create*(cx: int32, cy: int32, flags: WINUINT, cInitial: int32,

                        cGrow: int32): HIMAGELIST{.stdcall, dynlib: "comctl32",

     importc: "ImageList_Create".}

 proc ImageList_Destroy*(himl: HIMAGELIST): WINBOOL{.stdcall, dynlib: "comctl32",

@@ -20342,7 +20342,7 @@ proc ImageList_GetBkColor*(himl: HIMAGELIST): COLORREF{.stdcall,
 proc ImageList_SetOverlayImage*(himl: HIMAGELIST, iImage: int32, iOverlay: int32): WINBOOL{.

     stdcall, dynlib: "comctl32", importc: "ImageList_SetOverlayImage".}

 proc ImageList_Draw*(himl: HIMAGELIST, i: int32, hdcDst: HDC, x: int32,

-                     y: int32, fStyle: UINT): WINBOOL{.stdcall,

+                     y: int32, fStyle: WINUINT): WINBOOL{.stdcall,

     dynlib: "comctl32", importc: "ImageList_Draw".}

 proc ImageList_Replace*(himl: HIMAGELIST, i: int32, hbmImage: HBITMAP,

                         hbmMask: HBITMAP): WINBOOL{.stdcall, dynlib: "comctl32",

@@ -20351,11 +20351,11 @@ proc ImageList_AddMasked*(himl: HIMAGELIST, hbmImage: HBITMAP, crMask: COLORREF)
     stdcall, dynlib: "comctl32", importc: "ImageList_AddMasked".}

 proc ImageList_DrawEx*(himl: HIMAGELIST, i: int32, hdcDst: HDC, x: int32,

                        y: int32, dx: int32, dy: int32, rgbBk: COLORREF,

-                       rgbFg: COLORREF, fStyle: UINT): WINBOOL{.stdcall,

+                       rgbFg: COLORREF, fStyle: WINUINT): WINBOOL{.stdcall,

     dynlib: "comctl32", importc: "ImageList_DrawEx".}

 proc ImageList_Remove*(himl: HIMAGELIST, i: int32): WINBOOL{.stdcall,

     dynlib: "comctl32", importc: "ImageList_Remove".}

-proc ImageList_GetIcon*(himl: HIMAGELIST, i: int32, flags: UINT): HICON{.

+proc ImageList_GetIcon*(himl: HIMAGELIST, i: int32, flags: WINUINT): HICON{.

     stdcall, dynlib: "comctl32", importc: "ImageList_GetIcon".}

 proc ImageList_BeginDrag*(himlTrack: HIMAGELIST, iTrack: int32,

                           dxHotspot: int32, dyHotspot: int32): WINBOOL{.stdcall,

@@ -20385,20 +20385,20 @@ proc ImageList_GetImageInfo*(himl: HIMAGELIST, i: int32,
 proc ImageList_Merge*(himl1: HIMAGELIST, i1: int32, himl2: HIMAGELIST,

                       i2: int32, dx: int32, dy: int32): HIMAGELIST{.stdcall,

     dynlib: "comctl32", importc: "ImageList_Merge".}

-proc ImageList_SetImageCount*(himl: HIMAGELIST, uNewCount: UINT): int{.stdcall,

+proc ImageList_SetImageCount*(himl: HIMAGELIST, uNewCount: WINUINT): int{.stdcall,

     dynlib: "comctl32.dll", importc: "ImageList_SetImageCount".}

-proc CreateToolbarEx*(wnd: HWND, ws: DWORD, wID: UINT, nBitmaps: int32,

-                      hBMInst: HINST, wBMID: UINT, lpButtons: LPCTBBUTTON,

+proc CreateToolbarEx*(wnd: HWND, ws: DWORD, wID: WINUINT, nBitmaps: int32,

+                      hBMInst: HINST, wBMID: WINUINT, lpButtons: LPCTBBUTTON,

                       iNumButtons: int32, dxButton: int32, dyButton: int32,

-                      dxBitmap: int32, dyBitmap: int32, uStructSize: UINT): HWND{.

+                      dxBitmap: int32, dyBitmap: int32, uStructSize: WINUINT): HWND{.

     stdcall, dynlib: "comctl32", importc: "CreateToolbarEx".}

-proc CreateMappedBitmap*(hInstance: HINST, idBitmap: int32, wFlags: UINT,

+proc CreateMappedBitmap*(hInstance: HINST, idBitmap: int32, wFlags: WINUINT,

                          lpColorMap: LPCOLORMAP, iNumMaps: int32): HBITMAP{.

     stdcall, dynlib: "comctl32", importc: "CreateMappedBitmap".}

-proc MenuHelp*(uMsg: UINT, wp: WPARAM, lp: LPARAM, hMainMenu: HMENU,

-               hInst: HINST, hwndStatus: HWND, lpwIDs: var UINT){.stdcall,

+proc MenuHelp*(uMsg: WINUINT, wp: WPARAM, lp: LPARAM, hMainMenu: HMENU,

+               hInst: HINST, hwndStatus: HWND, lpwIDs: var WINUINT){.stdcall,

     dynlib: "comctl32", importc: "MenuHelp".}

-proc ShowHideMenuCtl*(wnd: HWND, uFlags: UINT, lpInfo: LPINT): WINBOOL{.

+proc ShowHideMenuCtl*(wnd: HWND, uFlags: WINUINT, lpInfo: LPINT): WINBOOL{.

     stdcall, dynlib: "comctl32", importc: "ShowHideMenuCtl".}

 proc GetEffectiveClientRect*(wnd: HWND, lprc: LPRECT, lpInfo: LPINT){.stdcall,

     dynlib: "comctl32", importc: "GetEffectiveClientRect".}

@@ -20428,21 +20428,21 @@ proc RegNotifyChangeKeyValue*(key: HKEY, bWatchSubtree: WINBOOL,
                               dwNotifyFilter: DWORD, hEvent: HANDLE,

                               fAsynchronus: WINBOOL): LONG{.stdcall,

     dynlib: "advapi32", importc: "RegNotifyChangeKeyValue".}

-proc IsValidCodePage*(CodePage: UINT): WINBOOL{.stdcall, dynlib: "kernel32",

+proc IsValidCodePage*(CodePage: WINUINT): WINBOOL{.stdcall, dynlib: "kernel32",

     importc: "IsValidCodePage".}

-proc GetACP*(): UINT{.stdcall, dynlib: "kernel32", importc: "GetACP".}

-proc GetOEMCP*(): UINT{.stdcall, dynlib: "kernel32", importc: "GetOEMCP".}

-proc GetCPInfo*(para1: UINT, para2: LPCPINFO): WINBOOL{.stdcall,

+proc GetACP*(): WINUINT{.stdcall, dynlib: "kernel32", importc: "GetACP".}

+proc GetOEMCP*(): WINUINT{.stdcall, dynlib: "kernel32", importc: "GetOEMCP".}

+proc GetCPInfo*(para1: WINUINT, para2: LPCPINFO): WINBOOL{.stdcall,

     dynlib: "kernel32", importc: "GetCPInfo".}

 proc IsDBCSLeadByte*(TestChar: int8): WINBOOL{.stdcall, dynlib: "kernel32",

     importc: "IsDBCSLeadByte".}

-proc IsDBCSLeadByteEx*(CodePage: UINT, TestChar: int8): WINBOOL{.stdcall,

+proc IsDBCSLeadByteEx*(CodePage: WINUINT, TestChar: int8): WINBOOL{.stdcall,

     dynlib: "kernel32", importc: "IsDBCSLeadByteEx".}

-proc MultiByteToWideChar*(CodePage: UINT, dwFlags: DWORD,

+proc MultiByteToWideChar*(CodePage: WINUINT, dwFlags: DWORD,

                           lpMultiByteStr: LPCSTR, cchMultiByte: int32,

                           lpWideCharStr: LPWSTR, cchWideChar: int32): int32{.

     stdcall, dynlib: "kernel32", importc: "MultiByteToWideChar".}

-proc WideCharToMultiByte*(CodePage: UINT, dwFlags: DWORD,

+proc WideCharToMultiByte*(CodePage: WINUINT, dwFlags: DWORD,

                           lpWideCharStr: LPCWSTR, cchWideChar: int32,

                           lpMultiByteStr: LPSTR, cchMultiByte: int32,

                           lpDefaultChar: LPCSTR, lpUsedDefaultChar: LPBOOL): int32{.

@@ -20520,12 +20520,12 @@ proc CreateConsoleScreenBuffer*(dwDesiredAccess: DWORD, dwShareMode: DWORD,
                                 lpSecurityAttributes: var SECURITY_ATTRIBUTES,

                                 dwFlags: DWORD, lpScreenBufferData: LPVOID): HANDLE{.

     stdcall, dynlib: "kernel32", importc: "CreateConsoleScreenBuffer".}

-proc GetConsoleCP*(): UINT{.stdcall, dynlib: "kernel32", importc: "GetConsoleCP".}

-proc SetConsoleCP*(wCodePageID: UINT): WINBOOL{.stdcall, dynlib: "kernel32",

+proc GetConsoleCP*(): WINUINT{.stdcall, dynlib: "kernel32", importc: "GetConsoleCP".}

+proc SetConsoleCP*(wCodePageID: WINUINT): WINBOOL{.stdcall, dynlib: "kernel32",

     importc: "SetConsoleCP".}

-proc GetConsoleOutputCP*(): UINT{.stdcall, dynlib: "kernel32",

+proc GetConsoleOutputCP*(): WINUINT{.stdcall, dynlib: "kernel32",

                                   importc: "GetConsoleOutputCP".}

-proc SetConsoleOutputCP*(wCodePageID: UINT): WINBOOL{.stdcall,

+proc SetConsoleOutputCP*(wCodePageID: WINUINT): WINBOOL{.stdcall,

     dynlib: "kernel32", importc: "SetConsoleOutputCP".}

 proc WNetConnectionDialog*(wnd: HWND, dwType: DWORD): DWORD{.stdcall,

     dynlib: "mpr", importc: "WNetConnectionDialog".}

@@ -20562,7 +20562,7 @@ proc UnlockServiceDatabase*(ScLock: SC_LOCK): WINBOOL{.stdcall,
     dynlib: "advapi32", importc: "UnlockServiceDatabase".}

 proc ChoosePixelFormat*(para1: HDC, para2: PPIXELFORMATDESCRIPTOR): int32{.

     stdcall, dynlib: "gdi32", importc: "ChoosePixelFormat".}

-proc DescribePixelFormat*(para1: HDC, para2: int32, para3: UINT,

+proc DescribePixelFormat*(para1: HDC, para2: int32, para3: WINUINT,

                           para4: LPPIXELFORMATDESCRIPTOR): int32{.stdcall,

     dynlib: "gdi32", importc: "DescribePixelFormat".}

 proc SetPixelFormat*(para1: HDC, para2: int32, para3: PPIXELFORMATDESCRIPTOR): WINBOOL{.

@@ -20584,7 +20584,7 @@ proc DdeAccessData*(para1: HDDEDATA, para2: PDWORD): PBYTE{.stdcall,
 proc DdeAddData*(para1: HDDEDATA, para2: PBYTE, para3: DWORD, para4: DWORD): HDDEDATA{.

     stdcall, dynlib: "user32", importc: "DdeAddData".}

 proc DdeClientTransaction*(para1: PBYTE, para2: DWORD, para3: HCONV, para4: HSZ,

-                           para5: UINT, para6: UINT, para7: DWORD, para8: PDWORD): HDDEDATA{.

+                           para5: WINUINT, para6: WINUINT, para7: DWORD, para8: PDWORD): HDDEDATA{.

     stdcall, dynlib: "user32", importc: "DdeClientTransaction".}

 proc DdeCmpStringHandles*(para1: HSZ, para2: HSZ): int32{.stdcall,

     dynlib: "user32", importc: "DdeCmpStringHandles".}

@@ -20594,13 +20594,13 @@ proc DdeConnectList*(para1: DWORD, para2: HSZ, para3: HSZ, para4: HCONVLIST,
                      para5: PCONVCONTEXT): HCONVLIST{.stdcall, dynlib: "user32",

     importc: "DdeConnectList".}

 proc DdeCreateDataHandle*(para1: DWORD, para2: LPBYTE, para3: DWORD,

-                          para4: DWORD, para5: HSZ, para6: UINT, para7: UINT): HDDEDATA{.

+                          para4: DWORD, para5: HSZ, para6: WINUINT, para7: WINUINT): HDDEDATA{.

     stdcall, dynlib: "user32", importc: "DdeCreateDataHandle".}

 proc DdeDisconnect*(para1: HCONV): WINBOOL{.stdcall, dynlib: "user32",

     importc: "DdeDisconnect".}

 proc DdeDisconnectList*(para1: HCONVLIST): WINBOOL{.stdcall, dynlib: "user32",

     importc: "DdeDisconnectList".}

-proc DdeEnableCallback*(para1: DWORD, para2: HCONV, para3: UINT): WINBOOL{.

+proc DdeEnableCallback*(para1: DWORD, para2: HCONV, para3: WINUINT): WINBOOL{.

     stdcall, dynlib: "user32", importc: "DdeEnableCallback".}

 proc DdeFreeDataHandle*(para1: HDDEDATA): WINBOOL{.stdcall, dynlib: "user32",

     importc: "DdeFreeDataHandle".}

@@ -20608,17 +20608,17 @@ proc DdeFreeStringHandle*(para1: DWORD, para2: HSZ): WINBOOL{.stdcall,
     dynlib: "user32", importc: "DdeFreeStringHandle".}

 proc DdeGetData*(para1: HDDEDATA, para2: LPBYTE, para3: DWORD, para4: DWORD): DWORD{.

     stdcall, dynlib: "user32", importc: "DdeGetData".}

-proc DdeGetLastError*(para1: DWORD): UINT{.stdcall, dynlib: "user32",

+proc DdeGetLastError*(para1: DWORD): WINUINT{.stdcall, dynlib: "user32",

     importc: "DdeGetLastError".}

 proc DdeImpersonateClient*(para1: HCONV): WINBOOL{.stdcall, dynlib: "user32",

     importc: "DdeImpersonateClient".}

 proc DdeKeepStringHandle*(para1: DWORD, para2: HSZ): WINBOOL{.stdcall,

     dynlib: "user32", importc: "DdeKeepStringHandle".}

-proc DdeNameService*(para1: DWORD, para2: HSZ, para3: HSZ, para4: UINT): HDDEDATA{.

+proc DdeNameService*(para1: DWORD, para2: HSZ, para3: HSZ, para4: WINUINT): HDDEDATA{.

     stdcall, dynlib: "user32", importc: "DdeNameService".}

 proc DdePostAdvise*(para1: DWORD, para2: HSZ, para3: HSZ): WINBOOL{.stdcall,

     dynlib: "user32", importc: "DdePostAdvise".}

-proc DdeQueryConvInfo*(para1: HCONV, para2: DWORD, para3: PCONVINFO): UINT{.

+proc DdeQueryConvInfo*(para1: HCONV, para2: DWORD, para3: PCONVINFO): WINUINT{.

     stdcall, dynlib: "user32", importc: "DdeQueryConvInfo".}

 proc DdeQueryNextServer*(para1: HCONVLIST, para2: HCONV): HCONV{.stdcall,

     dynlib: "user32", importc: "DdeQueryNextServer".}

@@ -20630,18 +20630,18 @@ proc DdeUnaccessData*(para1: HDDEDATA): WINBOOL{.stdcall, dynlib: "user32",
     importc: "DdeUnaccessData".}

 proc DdeUninitialize*(para1: DWORD): WINBOOL{.stdcall, dynlib: "user32",

     importc: "DdeUninitialize".}

-proc SHAddToRecentDocs*(para1: UINT, para2: LPCVOID){.stdcall,

+proc SHAddToRecentDocs*(para1: WINUINT, para2: LPCVOID){.stdcall,

     dynlib: "shell32", importc: "SHAddToRecentDocs".}

 proc SHBrowseForFolder*(para1: LPBROWSEINFO): LPITEMIDLIST{.stdcall,

     dynlib: "shell32", importc: "SHBrowseForFolder".}

-proc SHChangeNotify*(para1: LONG, para2: UINT, para3: LPCVOID, para4: LPCVOID){.

+proc SHChangeNotify*(para1: LONG, para2: WINUINT, para3: LPCVOID, para4: LPCVOID){.

     stdcall, dynlib: "shell32", importc: "SHChangeNotify".}

 proc SHFileOperation*(para1: LPSHFILEOPSTRUCT): int32{.stdcall,

     dynlib: "shell32", importc: "SHFileOperation".}

 proc SHFreeNameMappings*(para1: HANDLE){.stdcall, dynlib: "shell32",

     importc: "SHFreeNameMappings".}

 proc SHGetFileInfo*(para1: LPCTSTR, para2: DWORD, para3: var SHFILEINFO,

-                    para4: UINT, para5: UINT): DWORD{.stdcall,

+                    para4: WINUINT, para5: WINUINT): DWORD{.stdcall,

     dynlib: "shell32", importc: "SHGetFileInfo".}

 proc SHGetPathFromIDList*(para1: LPCITEMIDLIST, para2: LPTSTR): WINBOOL{.

     stdcall, dynlib: "shell32", importc: "SHGetPathFromIDList".}

@@ -20657,7 +20657,7 @@ proc wglCreateContext*(para1: HDC): HGLRC{.stdcall, dynlib: "opengl32",
     importc: "wglCreateContext".}

 proc wglCreateLayerContext*(para1: HDC, para2: int32): HGLRC{.stdcall,

     dynlib: "opengl32", importc: "wglCreateLayerContext".}

-proc wglCopyContext*(para1: HGLRC, para2: HGLRC, para3: UINT): WINBOOL{.stdcall,

+proc wglCopyContext*(para1: HGLRC, para2: HGLRC, para3: WINUINT): WINBOOL{.stdcall,

     dynlib: "opengl32", importc: "wglCopyContext".}

 proc wglDeleteContext*(para1: HGLRC): WINBOOL{.stdcall, dynlib: "opengl32",

     importc: "wglDeleteContext".}

@@ -20681,7 +20681,7 @@ proc wglUseFontOutlinesA*(para1: HDC, para2: DWORD, para3: DWORD, para4: DWORD,
                           para5: float32, para6: float32, para7: int32,

                           para8: LPGLYPHMETRICSFLOAT): WINBOOL{.stdcall,

     dynlib: "opengl32", importc: "wglUseFontOutlinesA".}

-proc wglDescribeLayerPlane*(para1: HDC, para2: int32, para3: int32, para4: UINT,

+proc wglDescribeLayerPlane*(para1: HDC, para2: int32, para3: int32, para4: WINUINT,

                             para5: LPLAYERPLANEDESCRIPTOR): WINBOOL{.stdcall,

     dynlib: "opengl32", importc: "wglDescribeLayerPlane".}

 proc wglGetLayerPaletteEntries*(para1: HDC, para2: int32, para3: int32,

@@ -20694,7 +20694,7 @@ proc wglRealizeLayerPalette*(para1: HDC, para2: int32, para3: WINBOOL): WINBOOL{
 proc wglSetLayerPaletteEntries*(para1: HDC, para2: int32, para3: int32,

                                 para4: int32, para5: var COLORREF): int32{.

     stdcall, dynlib: "opengl32", importc: "wglSetLayerPaletteEntries".}

-proc wglSwapLayerBuffers*(para1: HDC, para2: UINT): WINBOOL{.stdcall,

+proc wglSwapLayerBuffers*(para1: HDC, para2: WINUINT): WINBOOL{.stdcall,

     dynlib: "opengl32", importc: "wglSwapLayerBuffers".}

 proc wglUseFontOutlinesW*(para1: HDC, para2: DWORD, para3: DWORD, para4: DWORD,

                           para5: float32, para6: float32, para7: int32,

@@ -20703,7 +20703,7 @@ proc wglUseFontOutlinesW*(para1: HDC, para2: DWORD, para3: DWORD, para4: DWORD,
   # translated macros

 proc Animate_Create*(hWndP: HWND, id: HMENU, dwStyle: DWORD, hInstance: HINST): HWND

 proc Animate_Open*(wnd: HWND, szName: LPTSTR): LRESULT

-proc Animate_Play*(wnd: HWND, `from`, `to`: int32, rep: UINT): LRESULT

+proc Animate_Play*(wnd: HWND, `from`, `to`: int32, rep: WINUINT): LRESULT

 

 proc Animate_Stop*(wnd: HWND): LRESULT

 proc Animate_Close*(wnd: HWND): LRESULT

@@ -20734,7 +20734,7 @@ proc Header_GetItemCount*(hwndHD: HWND): int32
 proc Header_InsertItem*(hwndHD: HWND, index: int32, hdi: var HD_ITEM): int32

 proc Header_Layout*(hwndHD: HWND, layout: var HD_LAYOUT): WINBOOL

 proc Header_SetItem*(hwndHD: HWND, index: int32, hdi: var HD_ITEM): WINBOOL

-proc ListView_Arrange*(hwndLV: HWND, code: UINT): LRESULT

+proc ListView_Arrange*(hwndLV: HWND, code: WINUINT): LRESULT

 proc ListView_CreateDragImage*(wnd: HWND, i: int32, lpptUpLeft: LPPOINT): LRESULT

 proc ListView_DeleteAllItems*(wnd: HWND): LRESULT

 proc ListView_DeleteColumn*(wnd: HWND, iCol: int32): LRESULT

@@ -20769,7 +20769,7 @@ proc ListView_InsertItem*(wnd: HWND, item: var LV_ITEM): LRESULT
 proc ListView_RedrawItems*(hwndLV: HWND, iFirst, iLast: int32): LRESULT

 proc ListView_Scroll*(hwndLV: HWND, dx, dy: int32): LRESULT

 proc ListView_SetBkColor*(wnd: HWND, clrBk: COLORREF): LRESULT

-proc ListView_SetCallbackMask*(wnd: HWND, mask: UINT): LRESULT

+proc ListView_SetCallbackMask*(wnd: HWND, mask: WINUINT): LRESULT

 proc ListView_SetColumn*(wnd: HWND, iCol: int32, col: var LV_COLUMN): LRESULT

 proc ListView_SetColumnWidth*(wnd: HWND, iCol, cx: int32): LRESULT

 proc ListView_SetImageList*(wnd: HWND, himl: int32, iImageList: HIMAGELIST): LRESULT

@@ -20842,7 +20842,7 @@ proc TabCtrl_GetToolTips*(wnd: HWND): LRESULT
 proc TabCtrl_SetToolTips*(wnd: HWND, hwndTT: int32): LRESULT

 proc TabCtrl_GetCurFocus*(wnd: HWND): LRESULT

 proc TabCtrl_SetCurFocus*(wnd: HWND, i: int32): LRESULT

-proc SNDMSG*(wnd: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM): LRESULT

+proc SNDMSG*(wnd: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM): LRESULT

 proc CommDlg_OpenSave_GetSpecA*(hdlg: HWND, psz: LPSTR, cbmax: int32): LRESULT

 proc CommDlg_OpenSave_GetSpecW*(hdlg: HWND, psz: LPWSTR, cbmax: int32): LRESULT

 when defined(winUnicode):

@@ -20865,7 +20865,7 @@ proc CommDlg_OpenSave_GetFolderIDList*(hdlg: HWND, pidl: LPVOID, cbmax: int32):
 proc CommDlg_OpenSave_SetControlText*(hdlg: HWND, id: int32, text: LPSTR): LRESULT

 proc CommDlg_OpenSave_HideControl*(hdlg: HWND, id: int32): LRESULT

 proc CommDlg_OpenSave_SetDefExt*(hdlg: HWND, pszext: LPSTR): LRESULT

-proc GetNextWindow*(wnd: HWND, uCmd: UINT): HWND{.stdcall, dynlib: "user32",

+proc GetNextWindow*(wnd: HWND, uCmd: WINUINT): HWND{.stdcall, dynlib: "user32",

     importc: "GetWindow".}

 proc GlobalAllocPtr*(flags, cb: DWord): Pointer

 proc GlobalFreePtr*(lp: Pointer): Pointer

@@ -21183,9 +21183,9 @@ proc CreateDialogIndirectParam*(hInstance: HINST, lpTemplate: TDlgTemplate,
     dynlib: "user32", importc: "CreateDialogIndirectParamA".}

   #function CreateDialogIndirectParamA(hInstance: HINST; const lpTemplate: TDlgTemplate; hWndParent: HWND; lpDialogFunc: TFNDlgProc; dwInitParam: LPARAM): HWND; stdcall; external 'user32' name 'CreateDialogIndirectParamA';

   #function CreateDialogIndirectParamW(hInstance: HINST; const lpTemplate: TDlgTemplate; hWndParent: HWND; lpDialogFunc: TFNDlgProc; dwInitParam: LPARAM): HWND; stdcall; external 'user32' name 'CreateDialogIndirectParamW';

-  #function CreateDIBitmap(DC: HDC; var InfoHeader: TBitmapInfoHeader; dwUsage: DWORD; InitBits: PChar; var InitInfo: TBitmapInfo; wUsage: UINT): HBITMAP; stdcall; external 'gdi32' name 'CreateDIBitmap';

-  #function CreateDIBPatternBrushPt(const p1: Pointer; p2: UINT): HBRUSH; stdcall; external 'gdi32' name 'CreateDIBPatternBrushPt';

-  #function CreateDIBSection(DC: HDC; const p2: TBitmapInfo; p3: UINT; var p4: Pointer; p5: THandle; p6: DWORD): HBITMAP; stdcall; external 'gdi32' name 'CreateDIBSection';

+  #function CreateDIBitmap(DC: HDC; var InfoHeader: TBitmapInfoHeader; dwUsage: DWORD; InitBits: PChar; var InitInfo: TBitmapInfo; wUsage: WINUINT): HBITMAP; stdcall; external 'gdi32' name 'CreateDIBitmap';

+  #function CreateDIBPatternBrushPt(const p1: Pointer; p2: WINUINT): HBRUSH; stdcall; external 'gdi32' name 'CreateDIBPatternBrushPt';

+  #function CreateDIBSection(DC: HDC; const p2: TBitmapInfo; p3: WINUINT; var p4: Pointer; p5: THandle; p6: DWORD): HBITMAP; stdcall; external 'gdi32' name 'CreateDIBSection';

   #function CreateEllipticRgnIndirect(const p1: TRect): HRGN; stdcall; external 'gdi32' name 'CreateEllipticRgnIndirect';

   #function CreateFontIndirect(const p1: TLogFont): HFONT;stdcall; external 'gdi32' name 'CreateFontIndirectA';

   #function CreateFontIndirectA(const p1: TLogFontA): HFONT; stdcall; external 'gdi32' name 'CreateFontIndirectA';

@@ -21251,7 +21251,7 @@ proc DdeSetQualityOfService*(hWndClient: HWnd,
                              pqosPrev: PSecurityQualityOfService): WINBOOL{.

     stdcall, dynlib: "user32", importc: "DdeSetQualityOfService".}

   #function DeleteAce(var pAcl: TACL; dwAceIndex: DWORD): WINBOOL; stdcall; external 'advapi32' name 'DeleteAce';

-proc DescribePixelFormat*(DC: HDC, p2: int, p3: UINT,

+proc DescribePixelFormat*(DC: HDC, p2: int, p3: WINUINT,

                           p4: var TPixelFormatDescriptor): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "DescribePixelFormat".}

   #function DestroyPrivateObjectSecurity(var ObjectDescriptor: PSecurityDescriptor): WINBOOL; stdcall; external 'advapi32' name 'DestroyPrivateObjectSecurity';

@@ -21283,29 +21283,29 @@ proc DosDateTimeToFileTime*(wFatDate, wFatTime: int16, lpFileTime: var TFileTime
 proc DPtoLP*(DC: HDC, Points: pointer, Count: int): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "DPtoLP".}

   # function DrawAnimatedRects(wnd: HWND; idAni: Integer; const lprcFrom, lprcTo: TRect): WINBOOL; stdcall; external 'user32' name 'DrawAnimatedRects';

-  #function DrawCaption(p1: HWND; p2: HDC; const p3: TRect; p4: UINT): WINBOOL; stdcall; external 'user32' name 'DrawCaption';

-proc DrawEdge*(hdc: HDC, qrc: var TRect, edge: UINT, grfFlags: UINT): WINBOOL{.

+  #function DrawCaption(p1: HWND; p2: HDC; const p3: TRect; p4: WINUINT): WINBOOL; stdcall; external 'user32' name 'DrawCaption';

+proc DrawEdge*(hdc: HDC, qrc: var TRect, edge: WINUINT, grfFlags: WINUINT): WINBOOL{.

     stdcall, dynlib: "user32", importc: "DrawEdge".}

   #function DrawFocusRect(hDC: HDC; const lprc: TRect): WINBOOL; stdcall; external 'user32' name 'DrawFocusRect';

-proc DrawFrameControl*(DC: HDC, Rect: TRect, uType, uState: UINT): WINBOOL{.

+proc DrawFrameControl*(DC: HDC, Rect: TRect, uType, uState: WINUINT): WINBOOL{.

     stdcall, dynlib: "user32", importc: "DrawFrameControl".}

 proc DrawText*(hDC: HDC, lpString: cstring, nCount: int, lpRect: var TRect,

-               uFormat: UINT): int{.stdcall, dynlib: "user32",

+               uFormat: WINUINT): int{.stdcall, dynlib: "user32",

                                     importc: "DrawTextA".}

 proc DrawTextA*(hDC: HDC, lpString: LPCSTR, nCount: int, lpRect: var TRect,

-                uFormat: UINT): int{.stdcall, dynlib: "user32",

+                uFormat: WINUINT): int{.stdcall, dynlib: "user32",

                                      importc: "DrawTextA".}

 proc DrawTextEx*(DC: HDC, lpchText: cstring, cchText: int, p4: var TRect,

-                 dwDTFormat: UINT, DTParams: PDrawTextParams): int{.stdcall,

+                 dwDTFormat: WINUINT, DTParams: PDrawTextParams): int{.stdcall,

     dynlib: "user32", importc: "DrawTextExA".}

 proc DrawTextExA*(DC: HDC, lpchText: LPCSTR, cchText: int, p4: var TRect,

-                  dwDTFormat: UINT, DTParams: PDrawTextParams): int{.stdcall,

+                  dwDTFormat: WINUINT, DTParams: PDrawTextParams): int{.stdcall,

     dynlib: "user32", importc: "DrawTextExA".}

 proc DrawTextExW*(DC: HDC, lpchText: LPWSTR, cchText: int, p4: var TRect,

-                  dwDTFormat: UINT, DTParams: PDrawTextParams): int{.stdcall,

+                  dwDTFormat: WINUINT, DTParams: PDrawTextParams): int{.stdcall,

     dynlib: "user32", importc: "DrawTextExW".}

 proc DrawTextW*(hDC: HDC, lpString: LPWSTR, nCount: int, lpRect: var TRect,

-                uFormat: UINT): int{.stdcall, dynlib: "user32",

+                uFormat: WINUINT): int{.stdcall, dynlib: "user32",

                                      importc: "DrawTextW".}

   #function DuplicateTokenEx(hExistingToken: THandle; dwDesiredAccess: DWORD; lpTokenAttributes: PSecurityAttributes; ImpersonationLevel: TSecurityImpersonationLevel; TokenType: TTokenType; var phNewToken: THandle): WINBOOL;

   #  stdcall; external 'advapi32' name 'DuplicateTokenEx';

@@ -21377,9 +21377,9 @@ proc FindNextFileW*(hFindFile: THandle, lpFindFileData: var TWIN32FindDataW): WI
   #function FrameRect(hDC: HDC; const lprc: TRect; hbr: HBRUSH): Integer; stdcall; external 'user32' name 'FrameRect';

   #function GetAce(const pAcl: TACL; dwAceIndex: DWORD; var pAce: Pointer): WINBOOL; stdcall; external 'advapi32' name 'GetAce';

   #function GetAclInformation(const pAcl: TACL; pAclInformation: Pointer; nAclInformationLength: DWORD; dwAclInformationClass: TAclInformationClass): WINBOOL; stdcall; external 'advapi32' name 'GetAclInformation';

-  #function GetAltTabInfo(wnd: HWND; iItem: Integer; var pati: TAltTabInfo; pszItemText: PChar; cchItemText: UINT): WINBOOL;stdcall; external 'user32' name 'GetAltTabInfoA';

-  #function GetAltTabInfoA(wnd: HWND; iItem: Integer; var pati: TAltTabInfo; pszItemText: LPCSTR; cchItemText: UINT): WINBOOL;stdcall; external 'user32' name 'GetAltTabInfoA';

-  #function GetAltTabInfoW(wnd: HWND; iItem: Integer; var pati: TAltTabInfo; pszItemText: LPWSTR; cchItemText: UINT): WINBOOL;stdcall; external 'user32' name 'GetAltTabInfoW';

+  #function GetAltTabInfo(wnd: HWND; iItem: Integer; var pati: TAltTabInfo; pszItemText: PChar; cchItemText: WINUINT): WINBOOL;stdcall; external 'user32' name 'GetAltTabInfoA';

+  #function GetAltTabInfoA(wnd: HWND; iItem: Integer; var pati: TAltTabInfo; pszItemText: LPCSTR; cchItemText: WINUINT): WINBOOL;stdcall; external 'user32' name 'GetAltTabInfoA';

+  #function GetAltTabInfoW(wnd: HWND; iItem: Integer; var pati: TAltTabInfo; pszItemText: LPWSTR; cchItemText: WINUINT): WINBOOL;stdcall; external 'user32' name 'GetAltTabInfoW';

 proc GetAspectRatioFilterEx*(DC: HDC, p2: var TSize): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "GetAspectRatioFilterEx".}

 proc GetBinaryType*(lpApplicationName: cstring, lpBinaryType: var DWORD): WINBOOL{.

@@ -21390,24 +21390,24 @@ proc GetBinaryTypeW*(lpApplicationName: LPWSTR, lpBinaryType: var DWORD): WINBOO
     stdcall, dynlib: "kernel32", importc: "GetBinaryTypeW".}

 proc GetBitmapDimensionEx*(p1: HBITMAP, p2: var TSize): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "GetBitmapDimensionEx".}

-proc GetBoundsRect*(DC: HDC, p2: var TRect, p3: UINT): UINT{.stdcall,

+proc GetBoundsRect*(DC: HDC, p2: var TRect, p3: WINUINT): WINUINT{.stdcall,

     dynlib: "gdi32", importc: "GetBoundsRect".}

 proc GetBrushOrgEx*(DC: HDC, p2: var TPoint): WINBOOL{.stdcall, dynlib: "gdi32",

     importc: "GetBrushOrgEx".}

 proc GetCaretPos*(lpPoint: var TPoint): WINBOOL{.stdcall, dynlib: "user32",

     importc: "GetCaretPos".}

-proc GetCharABCWidths*(DC: HDC, p2, p3: UINT, ABCStructs: pointer): WINBOOL{.

+proc GetCharABCWidths*(DC: HDC, p2, p3: WINUINT, ABCStructs: pointer): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "GetCharABCWidthsA".}

-proc GetCharABCWidthsA*(DC: HDC, p2, p3: UINT, ABCStructs: pointer): WINBOOL{.

+proc GetCharABCWidthsA*(DC: HDC, p2, p3: WINUINT, ABCStructs: pointer): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "GetCharABCWidthsA".}

-proc GetCharABCWidthsFloat*(DC: HDC, p2, p3: UINT, ABCFloatSturcts: pointer): WINBOOL{.

+proc GetCharABCWidthsFloat*(DC: HDC, p2, p3: WINUINT, ABCFloatSturcts: pointer): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "GetCharABCWidthsFloatA".}

-proc GetCharABCWidthsFloatA*(DC: HDC, p2, p3: UINT, ABCFloatSturcts: pointer): WINBOOL{.

+proc GetCharABCWidthsFloatA*(DC: HDC, p2, p3: WINUINT, ABCFloatSturcts: pointer): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "GetCharABCWidthsFloatA".}

-proc GetCharABCWidthsFloatW*(DC: HDC, p2, p3: UINT, ABCFloatSturcts: pointer): WINBOOL{.

+proc GetCharABCWidthsFloatW*(DC: HDC, p2, p3: WINUINT, ABCFloatSturcts: pointer): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "GetCharABCWidthsFloatW".}

-  #function GetCharABCWidthsI(DC: HDC; p2, p3: UINT; p4: PWORD; const Widths): WINBOOL;stdcall; external 'gdi32' name 'GetCharABCWidthsI';

-proc GetCharABCWidthsW*(DC: HDC, p2, p3: UINT, ABCStructs: pointer): WINBOOL{.

+  #function GetCharABCWidthsI(DC: HDC; p2, p3: WINUINT; p4: PWORD; const Widths): WINBOOL;stdcall; external 'gdi32' name 'GetCharABCWidthsI';

+proc GetCharABCWidthsW*(DC: HDC, p2, p3: WINUINT, ABCStructs: pointer): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "GetCharABCWidthsW".}

 proc GetCharacterPlacement*(DC: HDC, p2: cstring, p3, p4: WINBOOL,

                             p5: var TGCPResults, p6: DWORD): DWORD{.stdcall,

@@ -21418,24 +21418,24 @@ proc GetCharacterPlacementA*(DC: HDC, p2: LPCSTR, p3, p4: WINBOOL,
 proc GetCharacterPlacementW*(DC: HDC, p2: LPWSTR, p3, p4: WINBOOL,

                              p5: var TGCPResults, p6: DWORD): DWORD{.stdcall,

     dynlib: "gdi32", importc: "GetCharacterPlacementW".}

-proc GetCharWidth*(DC: HDC, p2, p3: UINT, Widths: pointer): WINBOOL{.stdcall,

+proc GetCharWidth*(DC: HDC, p2, p3: WINUINT, Widths: pointer): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "GetCharWidthA".}

-proc GetCharWidth32*(DC: HDC, p2, p3: UINT, Widths: pointer): WINBOOL{.stdcall,

+proc GetCharWidth32*(DC: HDC, p2, p3: WINUINT, Widths: pointer): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "GetCharWidth32A".}

-proc GetCharWidth32A*(DC: HDC, p2, p3: UINT, Widths: pointer): WINBOOL{.stdcall,

+proc GetCharWidth32A*(DC: HDC, p2, p3: WINUINT, Widths: pointer): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "GetCharWidth32A".}

-proc GetCharWidth32W*(DC: HDC, p2, p3: UINT, Widths: pointer): WINBOOL{.stdcall,

+proc GetCharWidth32W*(DC: HDC, p2, p3: WINUINT, Widths: pointer): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "GetCharWidth32W".}

-proc GetCharWidthA*(DC: HDC, p2, p3: UINT, Widths: pointer): WINBOOL{.stdcall,

+proc GetCharWidthA*(DC: HDC, p2, p3: WINUINT, Widths: pointer): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "GetCharWidthA".}

-proc GetCharWidthFloat*(DC: HDC, p2, p3: UINT, Widths: pointer): WINBOOL{.

+proc GetCharWidthFloat*(DC: HDC, p2, p3: WINUINT, Widths: pointer): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "GetCharWidthFloatA".}

-proc GetCharWidthFloatA*(DC: HDC, p2, p3: UINT, Widths: pointer): WINBOOL{.

+proc GetCharWidthFloatA*(DC: HDC, p2, p3: WINUINT, Widths: pointer): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "GetCharWidthFloatA".}

-proc GetCharWidthFloatW*(DC: HDC, p2, p3: UINT, Widths: pointer): WINBOOL{.

+proc GetCharWidthFloatW*(DC: HDC, p2, p3: WINUINT, Widths: pointer): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "GetCharWidthFloatW".}

-  #function GetCharWidthI(DC: HDC; p2, p3: UINT; p4: PWORD; const Widths:pointer): WINBOOL;stdcall; external 'gdi32' name 'GetCharWidthI';

-proc GetCharWidthW*(DC: HDC, p2, p3: UINT, Widths: pointer): WINBOOL{.stdcall,

+  #function GetCharWidthI(DC: HDC; p2, p3: WINUINT; p4: PWORD; const Widths:pointer): WINBOOL;stdcall; external 'gdi32' name 'GetCharWidthI';

+proc GetCharWidthW*(DC: HDC, p2, p3: WINUINT, Widths: pointer): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "GetCharWidthW".}

 proc GetClassInfo*(hInstance: HINST, lpClassName: cstring,

                    lpWndClass: var TWndClass): WINBOOL{.stdcall,

@@ -21484,7 +21484,7 @@ proc GetConsoleMode*(hConsoleHandle: THandle, lpMode: var DWORD): WINBOOL{.
 proc GetConsoleScreenBufferInfo*(hConsoleOutput: THandle,

     lpConsoleScreenBufferInfo: var TConsoleScreenBufferInfo): WINBOOL{.stdcall,

     dynlib: "kernel32", importc: "GetConsoleScreenBufferInfo".}

-proc GetCPInfo*(CodePage: UINT, lpCPInfo: var TCPInfo): WINBOOL{.stdcall,

+proc GetCPInfo*(CodePage: WINUINT, lpCPInfo: var TCPInfo): WINBOOL{.stdcall,

     dynlib: "kernel32", importc: "GetCPInfo".}

   #function GetCurrentHwProfile(var lpHwProfileInfo: THWProfileInfo): WINBOOL;stdcall; external 'advapi32' name 'GetCurrentHwProfileA';

   #function GetCurrentHwProfileA(var lpHwProfileInfo: THWProfileInfoA): WINBOOL;stdcall; external 'advapi32' name 'GetCurrentHwProfileA';

@@ -21504,10 +21504,10 @@ proc GetDefaultCommConfigA*(lpszName: LPCSTR, lpCC: var TCommConfig,
 proc GetDefaultCommConfigW*(lpszName: LPWSTR, lpCC: var TCommConfig,

                             lpdwSize: var DWORD): WINBOOL{.stdcall,

     dynlib: "kernel32", importc: "GetDefaultCommConfigW".}

-proc GetDIBColorTable*(DC: HDC, p2, p3: UINT, RGBQuadStructs: pointer): UINT{.

+proc GetDIBColorTable*(DC: HDC, p2, p3: WINUINT, RGBQuadStructs: pointer): WINUINT{.

     stdcall, dynlib: "gdi32", importc: "GetDIBColorTable".}

-proc GetDIBits*(DC: HDC, Bitmap: HBitmap, StartScan, NumScans: UINT,

-                Bits: Pointer, BitInfo: var TBitmapInfo, Usage: UINT): int{.

+proc GetDIBits*(DC: HDC, Bitmap: HBitmap, StartScan, NumScans: WINUINT,

+                Bits: Pointer, BitInfo: var TBitmapInfo, Usage: WINUINT): int{.

     stdcall, dynlib: "gdi32", importc: "GetDIBits".}

 proc GetDiskFreeSpace*(lpRootPathName: cstring, lpSectorsPerCluster,

     lpBytesPerSector, lpNumberOfFreeClusters, lpTotalNumberOfClusters: var DWORD): WINBOOL{.

@@ -21539,7 +21539,7 @@ proc GetDiskFreeSpaceExA*(lpDirectoryName: LPCSTR, lpFreeBytesAvailableToCaller,
 proc GetDiskFreeSpaceExW*(lpDirectoryName: LPWSTR, lpFreeBytesAvailableToCaller,

     lpTotalNumberOfBytes: pLargeInteger, lpTotalNumberOfFreeBytes: PLargeInteger): WINBOOL{.

     stdcall, dynlib: "kernel32", importc: "GetDiskFreeSpaceExW".}

-  #function GetEnhMetaFilePixelFormat(p1: HENHMETAFILE; p2: Cardinal; var p3: TPixelFormatDescriptor): UINT;stdcall; external 'gdi32' name 'GetEnhMetaFilePixelFormat';

+  #function GetEnhMetaFilePixelFormat(p1: HENHMETAFILE; p2: Cardinal; var p3: TPixelFormatDescriptor): WINUINT;stdcall; external 'gdi32' name 'GetEnhMetaFilePixelFormat';

 proc GetExitCodeProcess*(hProcess: THandle, lpExitCode: var DWORD): WINBOOL{.

     stdcall, dynlib: "kernel32", importc: "GetExitCodeProcess".}

 proc GetExitCodeThread*(hThread: THandle, lpExitCode: var DWORD): WINBOOL{.

@@ -21559,13 +21559,13 @@ proc GetFileVersionInfoSizeW*(lptstrFilename: LPWSTR, lpdwHandle: var DWORD): DW
   # function GetFullPathName(lpFileName: PChar; nBufferLength: DWORD; lpBuffer: PChar; var lpFilePart: PChar): DWORD;stdcall; external 'kernel32' name 'GetFullPathNameA';

   # function GetFullPathNameA(lpFileName: LPCSTR; nBufferLength: DWORD; lpBuffer: LPCSTR; var lpFilePart: LPCSTR): DWORD; stdcall; external 'kernel32' name 'GetFullPathNameA';

   # function GetFullPathNameW(lpFileName: LPWSTR; nBufferLength: DWORD; lpBuffer: LPWSTR; var lpFilePart: LPWSTR): DWORD; stdcall; external 'kernel32' name 'GetFullPathNameW';

-proc GetGlyphOutline*(DC: HDC, p2, p3: UINT, p4: TGlyphMetrics, p5: DWORD,

+proc GetGlyphOutline*(DC: HDC, p2, p3: WINUINT, p4: TGlyphMetrics, p5: DWORD,

                       p6: Pointer, p7: TMat2): DWORD{.stdcall, dynlib: "gdi32",

     importc: "GetGlyphOutlineA".}

-proc GetGlyphOutlineA*(DC: HDC, p2, p3: UINT, p4: TGlyphMetrics, p5: DWORD,

+proc GetGlyphOutlineA*(DC: HDC, p2, p3: WINUINT, p4: TGlyphMetrics, p5: DWORD,

                        p6: Pointer, p7: TMat2): DWORD{.stdcall, dynlib: "gdi32",

     importc: "GetGlyphOutlineA".}

-proc GetGlyphOutlineW*(DC: HDC, p2, p3: UINT, p4: TGlyphMetrics, p5: DWORD,

+proc GetGlyphOutlineW*(DC: HDC, p2, p3: WINUINT, p4: TGlyphMetrics, p5: DWORD,

                        p6: Pointer, p7: TMat2): DWORD{.stdcall, dynlib: "gdi32",

     importc: "GetGlyphOutlineW".}

   #function GetGUIThreadInfo(idThread: DWORD; var pgui: TGUIThreadinfo): WINBOOL;stdcall; external 'user32' name 'GetGUIThreadInfo';

@@ -21579,7 +21579,7 @@ proc GetIconInfo*(icon: HICON, piconinfo: var TIconInfo): WINBOOL{.stdcall,
   #function GetKernelObjectSecurity(Handle: THandle; RequestedInformation: SECURITY_INFORMATION; pSecurityDescriptor: PSecurityDescriptor; nLength: DWORD; var lpnLengthNeeded: DWORD): WINBOOL; stdcall; external 'advapi32' name 'GetKernelObjectSecurity';

 proc GetKerningPairs*(DC: HDC, Count: DWORD, KerningPairs: pointer): DWORD{.

     stdcall, dynlib: "gdi32", importc: "GetKerningPairs".}

-proc GetKeyboardLayoutList*(nBuff: int, List: pointer): UINT{.stdcall,

+proc GetKeyboardLayoutList*(nBuff: int, List: pointer): WINUINT{.stdcall,

     dynlib: "user32", importc: "GetKeyboardLayoutList".}

   #function GetKeyboardState(var KeyState: TKeyboardState): WINBOOL; stdcall; external 'user32' name 'GetKeyboardState';

   #function GetLastInputInfo(var plii: TLastInputInfo): WINBOOL;stdcall; external 'user32' name 'GetLastInputInfo';

@@ -21606,24 +21606,24 @@ proc GetMailslotInfo*(hMailslot: THandle, lpMaxMessageSize: Pointer,
     dynlib: "kernel32", importc: "GetMailslotInfo".}

   #function GetMenuBarInfo(hend: HWND; idObject, idItem: Longint; var pmbi: TMenuBarInfo): WINBOOL;stdcall; external 'user32' name 'GetMenuBarInfo';

   #function GetMenuInfo(menu: HMENU; var lpmi: TMenuInfo): WINBOOL;stdcall; external 'user32' name 'GetMenuInfo';

-proc GetMenuItemInfo*(p1: HMENU, p2: UINT, p3: WINBOOL, p4: var TMenuItemInfo): WINBOOL{.

+proc GetMenuItemInfo*(p1: HMENU, p2: WINUINT, p3: WINBOOL, p4: var TMenuItemInfo): WINBOOL{.

     stdcall, dynlib: "user32", importc: "GetMenuItemInfoA".}

-proc GetMenuItemInfoA*(p1: HMENU, p2: UINT, p3: WINBOOL, p4: var TMenuItemInfoA): WINBOOL{.

+proc GetMenuItemInfoA*(p1: HMENU, p2: WINUINT, p3: WINBOOL, p4: var TMenuItemInfoA): WINBOOL{.

     stdcall, dynlib: "user32", importc: "GetMenuItemInfoA".}

-  #function GetMenuItemInfoW(p1: HMENU; p2: UINT; p3: WINBOOL; var p4: TMenuItemInfoW): WINBOOL; stdcall; external 'user32' name 'GetMenuItemInfoW';

-proc GetMenuItemRect*(wnd: HWND, menu: HMENU, uItem: UINT, lprcItem: var TRect): WINBOOL{.

+  #function GetMenuItemInfoW(p1: HMENU; p2: WINUINT; p3: WINBOOL; var p4: TMenuItemInfoW): WINBOOL; stdcall; external 'user32' name 'GetMenuItemInfoW';

+proc GetMenuItemRect*(wnd: HWND, menu: HMENU, uItem: WINUINT, lprcItem: var TRect): WINBOOL{.

     stdcall, dynlib: "user32", importc: "GetMenuItemRect".}

-proc GetMessage*(lpMsg: var TMsg, wnd: HWND, wMsgFilterMin, wMsgFilterMax: UINT): WINBOOL{.

+proc GetMessage*(lpMsg: var TMsg, wnd: HWND, wMsgFilterMin, wMsgFilterMax: WINUINT): WINBOOL{.

     stdcall, dynlib: "user32", importc: "GetMessageA".}

 proc GetMessageA*(lpMsg: var TMsg, wnd: HWND,

-                  wMsgFilterMin, wMsgFilterMax: UINT): WINBOOL{.stdcall,

+                  wMsgFilterMin, wMsgFilterMax: WINUINT): WINBOOL{.stdcall,

     dynlib: "user32", importc: "GetMessageA".}

 proc GetMessageW*(lpMsg: var TMsg, wnd: HWND,

-                  wMsgFilterMin, wMsgFilterMax: UINT): WINBOOL{.stdcall,

+                  wMsgFilterMin, wMsgFilterMax: WINUINT): WINBOOL{.stdcall,

     dynlib: "user32", importc: "GetMessageW".}

 proc GetMiterLimit*(DC: HDC, Limit: var float32): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "GetMiterLimit".}

-  #function GetMouseMovePoints(cbSize: UINT; var lppt, lpptBuf: TMouseMovePoint; nBufPoints: Integer; resolution: DWORD): Integer;stdcall; external 'user32' name 'GetMouseMovePoints';

+  #function GetMouseMovePoints(cbSize: WINUINT; var lppt, lpptBuf: TMouseMovePoint; nBufPoints: Integer; resolution: DWORD): Integer;stdcall; external 'user32' name 'GetMouseMovePoints';

 proc GetNamedPipeInfo*(hNamedPipe: THandle, lpFlags: var DWORD,

                        lpOutBufferSize, lpInBufferSize, lpMaxInstances: Pointer): WINBOOL{.

     stdcall, dynlib: "kernel32", importc: "GetNamedPipeInfo".}

@@ -21637,8 +21637,8 @@ proc GetNumberOfConsoleMouseButtons*(lpNumberOfMouseButtons: var DWORD): WINBOOL
 proc GetOverlappedResult*(hFile: THandle, lpOverlapped: TOverlapped,

                           lpNumberOfBytesTransferred: var DWORD, bWait: WINBOOL): WINBOOL{.

     stdcall, dynlib: "kernel32", importc: "GetOverlappedResult".}

-proc GetPaletteEntries*(Palette: HPALETTE, StartIndex, NumEntries: UINT,

-                        PaletteEntries: pointer): UINT{.stdcall,

+proc GetPaletteEntries*(Palette: HPALETTE, StartIndex, NumEntries: WINUINT,

+                        PaletteEntries: pointer): WINUINT{.stdcall,

     dynlib: "gdi32", importc: "GetPaletteEntries".}

 proc GetPath*(DC: HDC, Points, Types: pointer, nSize: int): int{.stdcall,

     dynlib: "gdi32", importc: "GetPath".}

@@ -21656,13 +21656,13 @@ proc GetPrivateProfileSectionNames*(lpszReturnBuffer: LPTSTR, nSize: DWORD,
                                     lpFileName: LPCTSTR): DWORD{.stdcall,

     dynlib: "kernel32", importc: "GetPrivateProfileSectionNamesA".}

 proc GetPrivateProfileStructA*(lpszSection, lpszKey: LPCSTR, lpStruct: LPVOID,

-                               uSizeStruct: UINT, szFile: LPCSTR): WINBOOL{.

+                               uSizeStruct: WINUINT, szFile: LPCSTR): WINBOOL{.

     stdcall, dynlib: "kernel32", importc: "GetPrivateProfileStructA".}

 proc GetPrivateProfileStructW*(lpszSection, lpszKey: LPCWSTR, lpStruct: LPVOID,

-                               uSizeStruct: UINT, szFile: LPCWSTR): WINBOOL{.

+                               uSizeStruct: WINUINT, szFile: LPCWSTR): WINBOOL{.

     stdcall, dynlib: "kernel32", importc: "GetPrivateProfileStructW".}

 proc GetPrivateProfileStruct*(lpszSection, lpszKey: LPCTSTR, lpStruct: LPVOID,

-                              uSizeStruct: UINT, szFile: LPCTSTR): WINBOOL{.

+                              uSizeStruct: WINUINT, szFile: LPCTSTR): WINBOOL{.

     stdcall, dynlib: "kernel32", importc: "GetPrivateProfileStructA".}

 proc GetProcessAffinityMask*(hProcess: THandle, lpProcessAffinityMask,

     lpSystemAffinityMask: var DWORD): WINBOOL{.stdcall, dynlib: "kernel32",

@@ -21685,7 +21685,7 @@ proc GetQueuedCompletionStatus*(CompletionPort: THandle,
                                 lpOverlapped: var POverlapped,

                                 dwMilliseconds: DWORD): WINBOOL{.stdcall,

     dynlib: "kernel32", importc: "GetQueuedCompletionStatus".}

-proc GetRasterizerCaps*(p1: var TRasterizerStatus, p2: UINT): WINBOOL{.stdcall,

+proc GetRasterizerCaps*(p1: var TRasterizerStatus, p2: WINUINT): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "GetRasterizerCaps".}

 proc GetRgnBox*(RGN: HRGN, p2: var TRect): int{.stdcall, dynlib: "gdi32",

     importc: "GetRgnBox".}

@@ -21715,8 +21715,8 @@ proc GetStringTypeExW*(Locale: LCID, dwInfoType: DWORD, lpSrcStr: LPWSTR,
 proc GetStringTypeW*(dwInfoType: DWORD, lpSrcStr: WCHAR, cchSrc: WINBOOL,

                      lpCharType: var int16): WINBOOL{.stdcall,

     dynlib: "kernel32", importc: "GetStringTypeW".}

-proc GetSystemPaletteEntries*(DC: HDC, StartIndex, NumEntries: UINT,

-                              PaletteEntries: pointer): UINT{.stdcall,

+proc GetSystemPaletteEntries*(DC: HDC, StartIndex, NumEntries: WINUINT,

+                              PaletteEntries: pointer): WINUINT{.stdcall,

     dynlib: "gdi32", importc: "GetSystemPaletteEntries".}

 proc GetSystemPowerStatus*(lpSystemPowerStatus: var TSystemPowerStatus): WINBOOL{.

     stdcall, dynlib: "kernel32", importc: "GetSystemPowerStatus".}

@@ -21859,9 +21859,9 @@ proc InitializeAcl*(pAcl: var TACL, nAclLength, dwAclRevision: DWORD): WINBOOL{.
 proc InitializeSid*(Sid: Pointer, pIdentifierAuthority: TSIDIdentifierAuthority,

                     nSubAuthorityCount: int8): WINBOOL{.stdcall,

     dynlib: "advapi32", importc: "InitializeSid".}

-proc InsertMenuItemA*(p1: HMENU, p2: UINT, p3: WINBOOL, p4: TMenuItemInfoA): WINBOOL{.

+proc InsertMenuItemA*(p1: HMENU, p2: WINUINT, p3: WINBOOL, p4: TMenuItemInfoA): WINBOOL{.

     stdcall, dynlib: "user32", importc: "InsertMenuItemA".}

-  #function InsertMenuItemW(p1: HMENU; p2: UINT; p3: WINBOOL; const p4: TMenuItemInfoW): WINBOOL; stdcall; external 'user32' name 'InsertMenuItemW';

+  #function InsertMenuItemW(p1: HMENU; p2: WINUINT; p3: WINBOOL; const p4: TMenuItemInfoW): WINBOOL; stdcall; external 'user32' name 'InsertMenuItemW';

 proc IntersectRect*(lprcDst: var TRect, lprcSrc1, lprcSrc2: TRect): WINBOOL{.

     stdcall, dynlib: "user32", importc: "IntersectRect".}

   #function InvertRect(hDC: HDC; const lprc: TRect): WINBOOL; stdcall; external 'user32' name 'InvertRect';

@@ -21967,7 +21967,7 @@ proc MakeSelfRelativeSD*(pAbsoluteSecurityDescriptor: PSecurityDescriptor,
     dynlib: "advapi32", importc: "MakeSelfRelativeSD".}

 proc MapDialogRect*(hDlg: HWND, lpRect: var TRect): WINBOOL{.stdcall,

     dynlib: "user32", importc: "MapDialogRect".}

-proc MapWindowPoints*(hWndFrom, hWndTo: HWND, lpPoints: pointer, cPoints: UINT): int{.

+proc MapWindowPoints*(hWndFrom, hWndTo: HWND, lpPoints: pointer, cPoints: WINUINT): int{.

     stdcall, dynlib: "user32", importc: "MapWindowPoints".}

 proc MessageBoxIndirect*(MsgBoxParams: TMsgBoxParams): WINBOOL{.stdcall,

     dynlib: "user32", importc: "MessageBoxIndirectA".}

@@ -21982,7 +21982,7 @@ proc MsgWaitForMultipleObjects*(nCount: DWORD, pHandles: pointer,
 proc MsgWaitForMultipleObjectsEx*(nCount: DWORD, pHandles: pointer,

                                   dwMilliseconds, dwWakeMask, dwFlags: DWORD): DWORD{.

     stdcall, dynlib: "user32", importc: "MsgWaitForMultipleObjectsEx".}

-  # function MultiByteToWideChar(CodePage: UINT; dwFlags: DWORD; const lpMultiByteStr: LPCSTR; cchMultiByte: Integer; lLPWSTRStr: LPWSTR; cchWideChar: Integer): Integer; stdcall; external 'kernel32' name 'MultiByteToWideChar';

+  # function MultiByteToWideChar(CodePage: WINUINT; dwFlags: DWORD; const lpMultiByteStr: LPCSTR; cchMultiByte: Integer; lLPWSTRStr: LPWSTR; cchWideChar: Integer): Integer; stdcall; external 'kernel32' name 'MultiByteToWideChar';

 proc ObjectOpenAuditAlarm*(SubsystemName: cstring, HandleId: Pointer,

                            ObjectTypeName: cstring, ObjectName: cstring,

                            pSecurityDescriptor: PSecurityDescriptor,

@@ -22031,7 +22031,7 @@ proc OffsetViewportOrgEx*(DC: HDC, X, Y: int, Points: pointer): WINBOOL{.
     stdcall, dynlib: "gdi32", importc: "OffsetViewportOrgEx".}

 proc OffsetWindowOrgEx*(DC: HDC, X, Y: int, Points: pointer): WINBOOL{.stdcall,

     dynlib: "gdi32", importc: "OffsetWindowOrgEx".}

-proc OpenFile*(lpFileName: LPCSTR, lpReOpenBuff: var TOFStruct, uStyle: UINT): HFILE{.

+proc OpenFile*(lpFileName: LPCSTR, lpReOpenBuff: var TOFStruct, uStyle: WINUINT): HFILE{.

     stdcall, dynlib: "kernel32", importc: "OpenFile".}

 proc OpenProcessToken*(ProcessHandle: THandle, DesiredAccess: DWORD,

                        TokenHandle: var THandle): WINBOOL{.stdcall,

@@ -22049,19 +22049,19 @@ proc PeekConsoleInputW*(hConsoleInput: THandle, lpBuffer: var TInputRecord,
                         nLength: DWORD, lpNumberOfEventsRead: var DWORD): WINBOOL{.

     stdcall, dynlib: "kernel32", importc: "PeekConsoleInputW".}

 proc PeekMessage*(lpMsg: var TMsg, wnd: HWND,

-                  wMsgFilterMin, wMsgFilterMax, wRemoveMsg: UINT): WINBOOL{.

+                  wMsgFilterMin, wMsgFilterMax, wRemoveMsg: WINUINT): WINBOOL{.

     stdcall, dynlib: "user32", importc: "PeekMessageA".}

 proc PeekMessageA*(lpMsg: var TMsg, wnd: HWND,

-                   wMsgFilterMin, wMsgFilterMax, wRemoveMsg: UINT): WINBOOL{.

+                   wMsgFilterMin, wMsgFilterMax, wRemoveMsg: WINUINT): WINBOOL{.

     stdcall, dynlib: "user32", importc: "PeekMessageA".}

 proc PeekMessageW*(lpMsg: var TMsg, wnd: HWND,

-                   wMsgFilterMin, wMsgFilterMax, wRemoveMsg: UINT): WINBOOL{.

+                   wMsgFilterMin, wMsgFilterMax, wRemoveMsg: WINUINT): WINBOOL{.

     stdcall, dynlib: "user32", importc: "PeekMessageW".}

   #function PlayEnhMetaFile(DC: HDC; p2: HENHMETAFILE; const p3: TRect): WINBOOL; stdcall; external 'gdi32' name 'PlayEnhMetaFile';

 proc PlayEnhMetaFileRecord*(DC: HDC, p2: var THandleTable, p3: TEnhMetaRecord,

-                            p4: UINT): WINBOOL{.stdcall, dynlib: "gdi32",

+                            p4: WINUINT): WINBOOL{.stdcall, dynlib: "gdi32",

     importc: "PlayEnhMetaFileRecord".}

-proc PlayMetaFileRecord*(DC: HDC, p2: THandleTable, p3: TMetaRecord, p4: UINT): WINBOOL{.

+proc PlayMetaFileRecord*(DC: HDC, p2: THandleTable, p3: TMetaRecord, p4: WINUINT): WINBOOL{.

     stdcall, dynlib: "gdi32", importc: "PlayMetaFileRecord".}

 proc PlgBlt*(DC: HDC, PointsArray: pointer, p3: HDC, p4, p5, p6, p7: int,

              p8: HBITMAP, p9, p10: int): WINBOOL{.stdcall, dynlib: "gdi32",

@@ -22328,21 +22328,21 @@ proc ScrollWindow*(wnd: HWND, XAmount: int32, YAmount: int32, rect: LPRECT,
     importc: "ScrollWindow".}

 proc ScrollWindowEx*(wnd: HWND, dx: int32, dy: int32, prcScroll: lpRECT,

                      prcClip: lpRECT, hrgnUpdate: HRGN, prcUpdate: LPRECT,

-                     flags: UINT): int32{.stdcall, dynlib: "user32",

+                     flags: WINUINT): int32{.stdcall, dynlib: "user32",

     importc: "ScrollWindowEx".}

   #function ScrollDC(DC: HDC; DX, DY: Integer; var Scroll, Clip: TRect; Rgn: HRGN; Update: PRect): WINBOOL; stdcall; external 'user32' name 'ScrollDC';

   #function SearchPath(lpPath, lpFileName, lpExtension: PChar; nBufferLength: DWORD; lpBuffer: PChar; var lpFilePart: PChar): DWORD;stdcall; external 'kernel32' name 'SearchPathA';

   #function SearchPathA(lpPath, lpFileName, lpExtension: LPCSTR; nBufferLength: DWORD; lpBuffer: LPCSTR; var lpFilePart: LPCSTR): DWORD; stdcall; external 'kernel32' name 'SearchPathA';

   #function SearchPathW(lpPath, lpFileName, lpExtension: LPWSTR; nBufferLength: DWORD; lpBuffer: LPWSTR; var lpFilePart: LPWSTR): DWORD; stdcall; external 'kernel32' name 'SearchPathW';

-  #function SendInput(cInputs: UINT; var pInputs: TInput; cbSize: Integer): UINT;stdcall; external 'user32' name 'SendInput';

-proc SendMessageTimeout*(wnd: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM,

-                         fuFlags, uTimeout: UINT, lpdwResult: var DWORD): LRESULT{.

+  #function SendInput(cInputs: WINUINT; var pInputs: TInput; cbSize: Integer): WINUINT;stdcall; external 'user32' name 'SendInput';

+proc SendMessageTimeout*(wnd: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM,

+                         fuFlags, uTimeout: WINUINT, lpdwResult: var DWORD): LRESULT{.

     stdcall, dynlib: "user32", importc: "SendMessageTimeoutA".}

-proc SendMessageTimeoutA*(wnd: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM,

-                          fuFlags, uTimeout: UINT, lpdwResult: var DWORD): LRESULT{.

+proc SendMessageTimeoutA*(wnd: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM,

+                          fuFlags, uTimeout: WINUINT, lpdwResult: var DWORD): LRESULT{.

     stdcall, dynlib: "user32", importc: "SendMessageTimeoutA".}

-proc SendMessageTimeoutW*(wnd: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM,

-                          fuFlags, uTimeout: UINT, lpdwResult: var DWORD): LRESULT{.

+proc SendMessageTimeoutW*(wnd: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM,

+                          fuFlags, uTimeout: WINUINT, lpdwResult: var DWORD): LRESULT{.

     stdcall, dynlib: "user32", importc: "SendMessageTimeoutW".}

   #function SetAclInformation(var pAcl: TACL; pAclInformation: Pointer; nAclInformationLength: DWORD; dwAclInformationClass: TAclInformationClass): WINBOOL; stdcall; external 'advapi32' name 'SetAclInformation';

   #function SetColorAdjustment(DC: HDC; const p2: TColorAdjustment): WINBOOL; stdcall; external 'gdi32' name 'SetColorAdjustment';

@@ -22356,13 +22356,13 @@ proc SetConsoleCursorInfo*(hConsoleOutput: THandle,
                            lpConsoleCursorInfo: TConsoleCursorInfo): WINBOOL{.

     stdcall, dynlib: "kernel32", importc: "SetConsoleCursorInfo".}

   #function SetConsoleWindowInfo(hConsoleOutput: THandle; bAbsolute: WINBOOL; const lpConsoleWindow: TSmallRect): WINBOOL; stdcall; external 'kernel32' name 'SetConsoleWindowInfo';

-proc SetDIBColorTable*(DC: HDC, p2, p3: UINT, RGBQuadSTructs: pointer): UINT{.

+proc SetDIBColorTable*(DC: HDC, p2, p3: WINUINT, RGBQuadSTructs: pointer): WINUINT{.

     stdcall, dynlib: "gdi32", importc: "SetDIBColorTable".}

-proc SetDIBits*(DC: HDC, Bitmap: HBITMAP, StartScan, NumScans: UINT,

-                Bits: Pointer, BitsInfo: var TBitmapInfo, Usage: UINT): int{.

+proc SetDIBits*(DC: HDC, Bitmap: HBITMAP, StartScan, NumScans: WINUINT,

+                Bits: Pointer, BitsInfo: var TBitmapInfo, Usage: WINUINT): int{.

     stdcall, dynlib: "gdi32", importc: "SetDIBits".}

-  #function SetDIBitsToDevice(DC: HDC; DestX, DestY: Integer; Width, Height: DWORD; SrcX, SrcY: Integer; nStartScan, NumScans: UINT; Bits: Pointer; var BitsInfo: TBitmapInfo; Usage: UINT): Integer; stdcall; external 'gdi32' name 'SetDIBitsToDevice';

-proc SetEnhMetaFileBits*(para1: UINT, para2: pointer): HENHMETAFILE{.stdcall,

+  #function SetDIBitsToDevice(DC: HDC; DestX, DestY: Integer; Width, Height: DWORD; SrcX, SrcY: Integer; nStartScan, NumScans: WINUINT; Bits: Pointer; var BitsInfo: TBitmapInfo; Usage: WINUINT): Integer; stdcall; external 'gdi32' name 'SetDIBitsToDevice';

+proc SetEnhMetaFileBits*(para1: WINUINT, para2: pointer): HENHMETAFILE{.stdcall,

     dynlib: "gdi32", importc: "SetEnhMetaFileBits".}

 proc SetFileTime*(hFile: HANDLE, lpCreationTime: var FILETIME,

                   lpLastAccessTime: var FILETIME, lpLastWriteTime: var FILETIME): WINBOOL{.

@@ -22370,18 +22370,18 @@ proc SetFileTime*(hFile: HANDLE, lpCreationTime: var FILETIME,
   #function SetKeyboardState(var KeyState: TKeyboardState): WINBOOL; stdcall; external 'user32' name 'SetKeyboardState';

   #function SetLocalTime(const lpSystemTime: TSystemTime): WINBOOL; stdcall; external 'kernel32' name 'SetLocalTime';

   #function SetMenuInfo(menu: HMENU; const lpcmi: TMenuInfo): WINBOOL;stdcall; external 'user32' name 'SetMenuInfo';

-proc SetMenuItemInfo*(p1: HMENU, p2: UINT, p3: WINBOOL, p4: TMenuItemInfo): WINBOOL{.

+proc SetMenuItemInfo*(p1: HMENU, p2: WINUINT, p3: WINBOOL, p4: TMenuItemInfo): WINBOOL{.

     stdcall, dynlib: "user32", importc: "SetMenuItemInfoA".}

-proc SetMenuItemInfoA*(p1: HMENU, p2: UINT, p3: WINBOOL, p4: TMenuItemInfoA): WINBOOL{.

+proc SetMenuItemInfoA*(p1: HMENU, p2: WINUINT, p3: WINBOOL, p4: TMenuItemInfoA): WINBOOL{.

     stdcall, dynlib: "user32", importc: "SetMenuItemInfoA".}

-  #function SetMenuItemInfoW(p1: HMENU; p2: UINT; p3: WINBOOL; const p4: TMenuItemInfoW): WINBOOL; stdcall; external 'user32' name 'SetMenuItemInfoW';

-proc SetMetaFileBitsEx*(p1: UINT, p2: cstring): HMETAFILE{.stdcall,

+  #function SetMenuItemInfoW(p1: HMENU; p2: WINUINT; p3: WINBOOL; const p4: TMenuItemInfoW): WINBOOL; stdcall; external 'user32' name 'SetMenuItemInfoW';

+proc SetMetaFileBitsEx*(p1: WINUINT, p2: cstring): HMETAFILE{.stdcall,

     dynlib: "gdi32", importc: "SetMetaFileBitsEx".}

 proc SetNamedPipeHandleState*(hNamedPipe: THandle, lpMode: var DWORD,

     lpMaxCollectionCount, lpCollectDataTimeout: Pointer): WINBOOL{.stdcall,

     dynlib: "kernel32", importc: "SetNamedPipeHandleState".}

-proc SetPaletteEntries*(Palette: HPALETTE, StartIndex, NumEntries: UINT,

-                        PaletteEntries: pointer): UINT{.stdcall,

+proc SetPaletteEntries*(Palette: HPALETTE, StartIndex, NumEntries: WINUINT,

+                        PaletteEntries: pointer): WINUINT{.stdcall,

     dynlib: "gdi32", importc: "SetPaletteEntries".}

   #function SetPrivateObjectSecurity(SecurityInformation: SECURITY_INFORMATION; ModificationDescriptor: PSecurityDescriptor; var ObjectsSecurityDescriptor: PSecurityDescriptor; const GenericMapping: TGenericMapping; Token: THandle): WINBOOL;

   #  stdcall; external 'advapi32' name 'SetPrivateObjectSecurity';

@@ -22407,7 +22407,7 @@ proc SetWaitableTimer*(hTimer: THandle, lpDueTime: var TLargeInteger,
                        lPeriod: int32, pfnCompletionRoutine: TFNTimerAPCRoutine,

                        lpArgToCompletionRoutine: Pointer, fResume: WINBOOL): WINBOOL{.

     stdcall, dynlib: "kernel32", importc: "SetWaitableTimer".}

-proc SetWinMetaFileBits*(p1: UINT, p2: cstring, p3: HDC, p4: TMetaFilePict): HENHMETAFILE{.

+proc SetWinMetaFileBits*(p1: WINUINT, p2: cstring, p3: HDC, p4: TMetaFilePict): HENHMETAFILE{.

     stdcall, dynlib: "gdi32", importc: "SetWinMetaFileBits".}

   #function SetWorldTransform(DC: HDC; const p2: TXForm): WINBOOL; stdcall; external 'gdi32' name 'SetWorldTransform';

 proc StartDoc*(DC: HDC, p2: TDocInfo): int{.stdcall, dynlib: "gdi32",

@@ -22415,7 +22415,7 @@ proc StartDoc*(DC: HDC, p2: TDocInfo): int{.stdcall, dynlib: "gdi32",
 proc StartDocA*(DC: HDC, p2: TDocInfoA): int{.stdcall, dynlib: "gdi32",

     importc: "StartDocA".}

   #function StartDocW(DC: HDC; const p2: TDocInfoW): Integer; stdcall; external 'gdi32' name 'StartDocW';

-  #function StretchDIBits(DC: HDC; DestX, DestY, DestWidth, DestHegiht, SrcX, SrcY, SrcWidth, SrcHeight: Integer; Bits: Pointer; var BitsInfo: TBitmapInfo; Usage: UINT; Rop: DWORD): Integer; stdcall; external 'gdi32' name 'StretchDIBits';

+  #function StretchDIBits(DC: HDC; DestX, DestY, DestWidth, DestHegiht, SrcX, SrcY, SrcWidth, SrcHeight: Integer; Bits: Pointer; var BitsInfo: TBitmapInfo; Usage: WINUINT; Rop: DWORD): Integer; stdcall; external 'gdi32' name 'StretchDIBits';

 proc SubtractRect*(lprcDst: var TRect, lprcSrc1, lprcSrc2: TRect): WINBOOL{.

     stdcall, dynlib: "user32", importc: "SubtractRect".}

 proc SystemTimeToFileTime*(lpSystemTime: TSystemTime, lpFileTime: var TFileTime): WINBOOL{.

@@ -22435,15 +22435,15 @@ proc TabbedTextOutW*(hDC: HDC, X, Y: int, lpString: LPWSTR,
                      nCount, nTabPositions: int, lpnTabStopPositions: pointer,

                      nTabOrigin: int): int32{.stdcall, dynlib: "user32",

     importc: "TabbedTextOutW".}

-  #function ToAscii(uVirtKey, uScanCode: UINT; const KeyState: TKeyboardState; lpChar: PChar; uFlags: UINT): Integer; stdcall; external 'user32' name 'ToAscii';

-  #function ToAsciiEx(uVirtKey: UINT; uScanCode: UINT; const KeyState: TKeyboardState; lpChar: PChar; uFlags: UINT; dwhkl: HKL): Integer; stdcall; external 'user32' name 'ToAsciiEx';

-  #function ToUnicode(wVirtKey, wScanCode: UINT; const KeyState: TKeyboardState; var pwszBuff; cchBuff: Integer; wFlags: UINT): Integer; stdcall; external 'user32' name 'ToUnicode';

+  #function ToAscii(uVirtKey, uScanCode: WINUINT; const KeyState: TKeyboardState; lpChar: PChar; uFlags: WINUINT): Integer; stdcall; external 'user32' name 'ToAscii';

+  #function ToAsciiEx(uVirtKey: WINUINT; uScanCode: WINUINT; const KeyState: TKeyboardState; lpChar: PChar; uFlags: WINUINT; dwhkl: HKL): Integer; stdcall; external 'user32' name 'ToAsciiEx';

+  #function ToUnicode(wVirtKey, wScanCode: WINUINT; const KeyState: TKeyboardState; var pwszBuff; cchBuff: Integer; wFlags: WINUINT): Integer; stdcall; external 'user32' name 'ToUnicode';

   # Careful, NT and higher only.

 proc TrackMouseEvent*(EventTrack: var TTrackMouseEvent): WINBOOL{.stdcall,

     dynlib: "user32", importc: "TrackMouseEvent".}

 proc TrackMouseEvent*(lpEventTrack: PTrackMouseEvent): WINBOOL{.stdcall,

     dynlib: "user32", importc: "TrackMouseEvent".}

-proc TrackPopupMenu*(menu: HMENU, uFlags: UINT, x: int32, y: int32,

+proc TrackPopupMenu*(menu: HMENU, uFlags: WINUINT, x: int32, y: int32,

                      nReserved: int32, wnd: HWND, prcRect: PRect): WINBOOL{.

     stdcall, dynlib: "user32", importc: "TrackPopupMenu".}

 proc TransactNamedPipe*(hNamedPipe: THandle, lpInBuffer: Pointer,

@@ -22464,7 +22464,7 @@ proc TranslateMDISysAccel*(hWndClient: HWND, lpMsg: TMsg): WINBOOL{.stdcall,
     dynlib: "user32", importc: "TranslateMDISysAccel".}

 proc TranslateMessage*(lpMsg: TMsg): WINBOOL{.stdcall, dynlib: "user32",

     importc: "TranslateMessage".}

-  #function TransparentDIBits(DC: HDC; p2, p3, p4, p5: Integer; const p6: Pointer; const p7: PBitmapInfo; p8: UINT; p9, p10, p11, p12: Integer; p13: UINT): WINBOOL;stdcall; external 'gdi32' name 'TransparentDIBits';

+  #function TransparentDIBits(DC: HDC; p2, p3, p4, p5: Integer; const p6: Pointer; const p7: PBitmapInfo; p8: WINUINT; p9, p10, p11, p12: Integer; p13: WINUINT): WINBOOL;stdcall; external 'gdi32' name 'TransparentDIBits';

 proc UnhandledExceptionFilter*(ExceptionInfo: TExceptionPointers): int32{.

     stdcall, dynlib: "kernel32", importc: "UnhandledExceptionFilter".}

 proc UnionRect*(lprcDst: var TRect, lprcSrc1, lprcSrc2: TRect): WINBOOL{.

@@ -22474,39 +22474,39 @@ proc UnlockFileEx*(hFile: THandle, dwReserved, nNumberOfBytesToUnlockLow: DWORD,
     stdcall, dynlib: "kernel32", importc: "UnlockFileEx".}

 proc VerFindFile*(uFlags: DWORD,

                   szFileName, szWinDir, szAppDir, szCurDir: cstring,

-                  lpuCurDirLen: var UINT, szDestDir: cstring,

-                  lpuDestDirLen: var UINT): DWORD{.stdcall, dynlib: "version",

+                  lpuCurDirLen: var WINUINT, szDestDir: cstring,

+                  lpuDestDirLen: var WINUINT): DWORD{.stdcall, dynlib: "version",

     importc: "VerFindFileA".}

 proc VerFindFileA*(uFlags: DWORD,

                    szFileName, szWinDir, szAppDir, szCurDir: LPCSTR,

-                   lpuCurDirLen: var UINT, szDestDir: LPCSTR,

-                   lpuDestDirLen: var UINT): DWORD{.stdcall, dynlib: "version",

+                   lpuCurDirLen: var WINUINT, szDestDir: LPCSTR,

+                   lpuDestDirLen: var WINUINT): DWORD{.stdcall, dynlib: "version",

     importc: "VerFindFileA".}

 proc VerFindFileW*(uFlags: DWORD,

                    szFileName, szWinDir, szAppDir, szCurDir: LPWSTR,

-                   lpuCurDirLen: var UINT, szDestDir: LPWSTR,

-                   lpuDestDirLen: var UINT): DWORD{.stdcall, dynlib: "version",

+                   lpuCurDirLen: var WINUINT, szDestDir: LPWSTR,

+                   lpuDestDirLen: var WINUINT): DWORD{.stdcall, dynlib: "version",

     importc: "VerFindFileW".}

 proc VerInstallFile*(uFlags: DWORD, szSrcFileName, szDestFileName, szSrcDir,

                                     szDestDir, szCurDir, szTmpFile: cstring,

-                     lpuTmpFileLen: var UINT): DWORD{.stdcall,

+                     lpuTmpFileLen: var WINUINT): DWORD{.stdcall,

     dynlib: "version", importc: "VerInstallFileA".}

 proc VerInstallFileA*(uFlags: DWORD, szSrcFileName, szDestFileName, szSrcDir,

                                      szDestDir, szCurDir, szTmpFile: LPCSTR,

-                      lpuTmpFileLen: var UINT): DWORD{.stdcall,

+                      lpuTmpFileLen: var WINUINT): DWORD{.stdcall,

     dynlib: "version", importc: "VerInstallFileA".}

 proc VerInstallFileW*(uFlags: DWORD, szSrcFileName, szDestFileName, szSrcDir,

                                      szDestDir, szCurDir, szTmpFile: LPWSTR,

-                      lpuTmpFileLen: var UINT): DWORD{.stdcall,

+                      lpuTmpFileLen: var WINUINT): DWORD{.stdcall,

     dynlib: "version", importc: "VerInstallFileW".}

 proc VerQueryValue*(pBlock: Pointer, lpSubBlock: cstring,

-                    lplpBuffer: var Pointer, puLen: var UINT): WINBOOL{.stdcall,

+                    lplpBuffer: var Pointer, puLen: var WINUINT): WINBOOL{.stdcall,

     dynlib: "version", importc: "VerQueryValueA".}

 proc VerQueryValueA*(pBlock: Pointer, lpSubBlock: LPCSTR,

-                     lplpBuffer: var Pointer, puLen: var UINT): WINBOOL{.

+                     lplpBuffer: var Pointer, puLen: var WINUINT): WINBOOL{.

     stdcall, dynlib: "version", importc: "VerQueryValueA".}

 proc VerQueryValueW*(pBlock: Pointer, lpSubBlock: LPWSTR,

-                     lplpBuffer: var Pointer, puLen: var UINT): WINBOOL{.

+                     lplpBuffer: var Pointer, puLen: var WINUINT): WINBOOL{.

     stdcall, dynlib: "version", importc: "VerQueryValueW".}

 proc VirtualQuery*(lpAddress: Pointer, lpBuffer: var TMemoryBasicInformation,

                    dwLength: DWORD): DWORD{.stdcall, dynlib: "kernel32",

@@ -22526,7 +22526,7 @@ proc wglGetLayerPaletteEntries*(p1: HDC, p2, p3, p4: int, pcr: pointer): int{.
     stdcall, dynlib: "opengl32", importc: "wglGetLayerPaletteEntries".}

 proc wglSetLayerPaletteEntries*(p1: HDC, p2, p3, p4: int, pcr: pointer): int{.

     stdcall, dynlib: "opengl32", importc: "wglSetLayerPaletteEntries".}

-  #function wglSwapMultipleBuffers(p1: UINT; const p2: PWGLSwap): DWORD;stdcall; external 'opengl32' name 'wglSwapMultipleBuffers';

+  #function wglSwapMultipleBuffers(p1: WINUINT; const p2: PWGLSwap): DWORD;stdcall; external 'opengl32' name 'wglSwapMultipleBuffers';

   #function WinSubmitCertificate(var lpCertificate: TWinCertificate): WINBOOL;stdcall; external 'imaghlp' name 'WinSubmitCertificate';

   #function WinVerifyTrust(wnd: HWND; const ActionID: TGUID; ActionData: Pointer): Longint;stdcall; external 'imaghlp' name 'WinVerifyTrust';

 proc WNetAddConnection2*(lpNetResource: var TNetResource,

@@ -22698,14 +22698,14 @@ proc WriteFileEx*(hFile: THandle, lpBuffer: Pointer,
                   lpCompletionRoutine: FARPROC): WINBOOL{.stdcall,

     dynlib: "kernel32", importc: "WriteFileEx".}

 proc WritePrivateProfileStructA*(lpszSection, lpszKey: LPCSTR, lpStruct: LPVOID,

-                                 uSizeStruct: UINT, szFile: LPCSTR): WINBOOL{.

+                                 uSizeStruct: WINUINT, szFile: LPCSTR): WINBOOL{.

     stdcall, dynlib: "kernel32", importc: "WritePrivateProfileStructA".}

 proc WritePrivateProfileStructW*(lpszSection, lpszKey: LPCWSTR,

-                                 lpStruct: LPVOID, uSizeStruct: UINT,

+                                 lpStruct: LPVOID, uSizeStruct: WINUINT,

                                  szFile: LPCWSTR): WINBOOL{.stdcall,

     dynlib: "kernel32", importc: "WritePrivateProfileStructW".}

 proc WritePrivateProfileStruct*(lpszSection, lpszKey: LPCTSTR, lpStruct: LPVOID,

-                                uSizeStruct: UINT, szFile: LPCTSTR): WINBOOL{.

+                                uSizeStruct: WINUINT, szFile: LPCTSTR): WINBOOL{.

     stdcall, dynlib: "kernel32", importc: "WritePrivateProfileStructA".}

 proc WriteProcessMemory*(hProcess: THandle, lpBaseAddress: Pointer,

                          lpBuffer: Pointer, nSize: DWORD,

@@ -22758,12 +22758,12 @@ proc LocalDiscard*(hlocMem: HLOCAL): HLOCAL =
 

 # WinGDI.h

 

-proc GetGValue*(rgb: int32): int8 =

-  result = toU8(rgb shr 8'i32)

+discard """proc GetGValue*(rgb: int32): int8 =

+  result = toU8(rgb shr 8'i32)"""

 proc RGB*(r, g, b: int): COLORREF =

   result = toU32(r) or (toU32(g) shl 8) or (toU32(b) shl 16)

 proc RGB*(r, g, b: range[0 .. 255]): COLORREF =

-  result = r or g shl 8 or b shl 16

+  result = toU32(r) or (toU32(g) shl 8) or (toU32(b) shl 16)

 

 proc PALETTERGB*(r, g, b: range[0..255]): COLORREF =

   result = 0x02000000 or RGB(r, g, b)

@@ -23363,7 +23363,7 @@ proc Animate_Create(hWndP: HWND, id: HMENU, dwStyle: DWORD, hInstance: HINST): H
 proc Animate_Open(wnd: HWND, szName: LPTSTR): LRESULT =

   result = SendMessage(wnd, ACM_OPEN, 0, cast[LPARAM](szName))

 

-proc Animate_Play(wnd: HWND, `from`, `to`: int32, rep: UINT): LRESULT =

+proc Animate_Play(wnd: HWND, `from`, `to`: int32, rep: WINUINT): LRESULT =

   result = SendMessage(wnd, ACM_PLAY, WPARAM(rep),

                        LPARAM(MAKELONG(`from`, `to`)))

 

@@ -23458,7 +23458,7 @@ proc Header_SetItem(hwndHD: HWND, index: int32, hdi: var HD_ITEM): WINBOOL =
   result = WINBOOL(SendMessage(hwndHD, HDM_SETITEM, WPARAM(index),

                                cast[LPARAM](addr(hdi))))

 

-proc ListView_Arrange(hwndLV: HWND, code: UINT): LRESULT =

+proc ListView_Arrange(hwndLV: HWND, code: WINUINT): LRESULT =

   result = SendMessage(hwndLV, LVM_ARRANGE, WPARAM(code), 0)

 

 proc ListView_CreateDragImage(wnd: HWND, i: int32, lpptUpLeft: LPPOINT): LRESULT =

@@ -23481,7 +23481,7 @@ proc ListView_EnsureVisible(hwndLV: HWND, i, fPartialOK: int32): LRESULT =
                        MAKELPARAM(fPartialOK, 0))

 

 proc ListView_FindItem(wnd: HWND, iStart: int32, lvfi: var LV_FINDINFO): int32 =

-  result = SendMessage(wnd, LVM_FINDITEM, WPARAM(iStart), 
+  result = SendMessage(wnd, LVM_FINDITEM, WPARAM(iStart), 

                        cast[LPARAM](addr(lvfi))).int32

 

 proc ListView_GetBkColor(wnd: HWND): LRESULT =

@@ -23566,7 +23566,7 @@ proc ListView_Scroll(hwndLV: HWND, dx, dy: int32): LRESULT =
 proc ListView_SetBkColor(wnd: HWND, clrBk: COLORREF): LRESULT =

   result = SendMessage(wnd, LVM_SETBKCOLOR, 0, LPARAM(clrBk))

 

-proc ListView_SetCallbackMask(wnd: HWND, mask: UINT): LRESULT =

+proc ListView_SetCallbackMask(wnd: HWND, mask: WINUINT): LRESULT =

   result = SendMessage(wnd, LVM_SETCALLBACKMASK, WPARAM(mask), 0)

 

 proc ListView_SetColumn(wnd: HWND, iCol: int32, col: var LV_COLUMN): LRESULT =

@@ -23577,7 +23577,7 @@ proc ListView_SetColumnWidth(wnd: HWND, iCol, cx: int32): LRESULT =
 

 proc ListView_SetImageList(wnd: HWND, himl: int32, iImageList: HIMAGELIST): LRESULT =

   result = SendMessage(wnd, LVM_SETIMAGELIST, WPARAM(iImageList),

-                       LPARAM(UINT(himl)))

+                       LPARAM(WINUINT(himl)))

 

 proc ListView_SetItem(wnd: HWND, item: var LV_ITEM): LRESULT =

   result = SendMessage(wnd, LVM_SETITEM, 0, cast[LPARAM](addr(item)))

@@ -23597,8 +23597,8 @@ proc ListView_SetItemPosition32(hwndLV: HWND, i, x, y: int32): LRESULT =
 

 proc ListView_SetItemState(hwndLV: HWND, i, data, mask: int32): LRESULT =

   var gnu_lvi: LV_ITEM

-  gnu_lvi.stateMask = uint(mask)

-  gnu_lvi.state = uint(data)

+  gnu_lvi.stateMask = WINUINT(mask)

+  gnu_lvi.state = WINUINT(data)

   result = SendMessage(hwndLV, LVM_SETITEMSTATE, WPARAM(i),

                        cast[LPARAM](addr(gnu_lvi)))

 

@@ -23648,7 +23648,7 @@ proc TreeView_GetImageList(wnd: HWND, iImage: WPARAM): LRESULT =
   result = SendMessage(wnd, TVM_GETIMAGELIST, iImage, 0)

 

 proc TreeView_SetImageList(wnd: HWND, himl: HIMAGELIST, iImage: WPARAM): LRESULT =

-  result = SendMessage(wnd, TVM_SETIMAGELIST, iImage, LPARAM(UINT(himl)))

+  result = SendMessage(wnd, TVM_SETIMAGELIST, iImage, LPARAM(WINUINT(himl)))

 

 proc TreeView_GetNextItem(wnd: HWND, hitem: HTREEITEM, code: int32): LRESULT =

   result = SendMessage(wnd, TVM_GETNEXTITEM, WPARAM(code), cast[LPARAM](hitem))

@@ -23735,7 +23735,7 @@ proc TabCtrl_GetImageList(wnd: HWND): LRESULT =
   result = SendMessage(wnd, TCM_GETIMAGELIST, 0, 0)

 

 proc TabCtrl_SetImageList(wnd: HWND, himl: HIMAGELIST): LRESULT =

-  result = SendMessage(wnd, TCM_SETIMAGELIST, 0, LPARAM(UINT(himl)))

+  result = SendMessage(wnd, TCM_SETIMAGELIST, 0, LPARAM(WINUINT(himl)))

 

 proc TabCtrl_GetItemCount(wnd: HWND): LRESULT =

   result = SendMessage(wnd, TCM_GETITEMCOUNT, 0, 0)

@@ -23797,7 +23797,7 @@ proc TabCtrl_GetCurFocus(wnd: HWND): LRESULT =
 proc TabCtrl_SetCurFocus(wnd: HWND, i: int32): LRESULT =

   result = SendMessage(wnd, TCM_SETCURFOCUS, i, 0)

 

-proc SNDMSG(wnd: HWND, Msg: UINT, wp: WPARAM, lp: LPARAM): LRESULT =

+proc SNDMSG(wnd: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM): LRESULT =

   result = SendMessage(wnd, Msg, wp, lp)

 

 proc CommDlg_OpenSave_GetSpecA(hdlg: HWND, psz: LPSTR, cbmax: int32): LRESULT =

diff --git a/lib/windows/winlean.nim b/lib/windows/winlean.nim
index 4ce2f11b4..dcae6ffaf 100644
--- a/lib/windows/winlean.nim
+++ b/lib/windows/winlean.nim
@@ -639,9 +639,9 @@ proc unmapViewOfFile*(lpBaseAddress: pointer): WINBOOL {.stdcall,
     dynlib: "kernel32", importc: "UnmapViewOfFile".}
 
 type
-  TOVERLAPPED* {.final, pure.} = object
-    Internal*: DWORD
-    InternalHigh*: DWORD
+  TOVERLAPPED* {.pure, inheritable.} = object
+    Internal*: PULONG
+    InternalHigh*: PULONG
     Offset*: DWORD
     OffsetHigh*: DWORD
     hEvent*: THANDLE
@@ -718,4 +718,12 @@ proc WSASend*(s: TSocketHandle, buf: ptr TWSABuf, bufCount: DWORD,
   stdcall, importc: "WSASend", dynlib: "Ws2_32.dll".}
 
 proc get_osfhandle*(fd:TFileHandle): THandle {.
-  importc:"_get_osfhandle", header:"<io.h>".}
+  importc: "_get_osfhandle", header:"<io.h>".}
+
+proc getSystemTimes*(lpIdleTime, lpKernelTime, 
+                     lpUserTime: var TFILETIME): WINBOOL {.stdcall,
+  dynlib: "kernel32", importc: "GetSystemTimes".}
+
+proc getProcessTimes*(hProcess: THandle; lpCreationTime, lpExitTime,
+  lpKernelTime, lpUserTime: var TFILETIME): WINBOOL {.stdcall,
+  dynlib: "kernel32", importc: "GetProcessTimes".}
diff --git a/lib/wrappers/openssl.nim b/lib/wrappers/openssl.nim
index 90c398dce..4dc71bffd 100644
--- a/lib/wrappers/openssl.nim
+++ b/lib/wrappers/openssl.nim
@@ -270,7 +270,7 @@ proc OPENSSL_config*(configName: cstring){.cdecl, dynlib: DLLSSLName, importc.}
 
 when not defined(windows):
   proc CRYPTO_set_mem_functions(a,b,c: pointer){.cdecl, 
-    dynlib: DLLSSLName, importc.}
+    dynlib: DLLUtilName, importc.}
 
 proc CRYPTO_malloc_init*() =
   when not defined(windows):
@@ -433,3 +433,70 @@ else:
   proc SSLGetMode(s: PSSL): int = 
     result = SSLctrl(s, SSL_CTRL_MODE, 0, nil)
 
+# <openssl/md5.h>
+type 
+  MD5_LONG* = cuint
+const 
+  MD5_CBLOCK* = 64
+  MD5_LBLOCK* = int(MD5_CBLOCK div 4)
+  MD5_DIGEST_LENGTH* = 16
+type 
+  MD5_CTX* = object 
+    A,B,C,D,Nl,Nh: MD5_LONG
+    data: array[MD5_LBLOCK, MD5_LONG]
+    num: cuint
+
+{.pragma: ic, importc: "$1".}
+{.push callconv:cdecl, dynlib:DLLUtilName.}
+proc MD5_Init*(c: var MD5_CTX): cint{.ic.}
+proc MD5_Update*(c: var MD5_CTX; data: pointer; len: csize): cint{.ic.}
+proc MD5_Final*(md: cstring; c: var MD5_CTX): cint{.ic.}
+proc MD5*(d: ptr cuchar; n: csize; md: ptr cuchar): ptr cuchar{.ic.}
+proc MD5_Transform*(c: var MD5_CTX; b: ptr cuchar){.ic.}
+{.pop.}
+
+from strutils import toHex,toLower
+
+proc hexStr (buf:cstring): string =
+  # turn md5s output into a nice hex str 
+  result = newStringOfCap(32)
+  for i in 0 .. <16:
+    result.add toHex(buf[i].ord, 2).toLower
+
+proc MD5_File* (file: string): string {.raises:[EIO,Ebase].} =
+  ## Generate MD5 hash for a file. Result is a 32 character
+  # hex string with lowercase characters (like the output
+  # of `md5sum`
+  const
+    sz = 512
+  let f = open(file,fmRead)
+  var
+    buf: array[sz,char]
+    ctx: MD5_CTX
+
+  discard md5_init(ctx)
+  while(let bytes = f.readChars(buf, 0, sz); bytes > 0):
+    discard md5_update(ctx, buf[0].addr, bytes)
+
+  discard md5_final( buf[0].addr, ctx )
+  f.close
+  
+  result = hexStr(buf)
+
+proc MD5_Str* (str:string): string {.raises:[EIO].} =
+  ##Generate MD5 hash for a string. Result is a 32 character
+  #hex string with lowercase characters
+  var 
+    ctx: MD5_CTX
+    res: array[MD5_DIGEST_LENGTH,char]
+    input = str.cstring
+  discard md5_init(ctx)
+
+  var i = 0
+  while i < str.len:
+    let L = min(str.len - i, 512)
+    discard md5_update(ctx, input[i].addr, L)
+    i += L
+
+  discard md5_final(res,ctx)
+  result = hexStr(res)
diff --git a/lib/wrappers/pdcurses.nim b/lib/wrappers/pdcurses.nim
index f014c5e9c..a53289bce 100644
--- a/lib/wrappers/pdcurses.nim
+++ b/lib/wrappers/pdcurses.nim
@@ -554,14 +554,12 @@ template BUTTON_CHANGED*(x: expr): expr =
 template BUTTON_STATUS*(x: expr): expr = 
   (Mouse_status.button[(x) - 1])
 
-template ACS_PICK*(w, n: expr): expr = 
-  (cast[int32](w) or A_ALTCHARSET)
+template ACS_PICK*(w, n: expr): expr = int32(w) or A_ALTCHARSET
 
-template KEY_F*(n: expr): expr = 
-  (KEY_F0 + (n))
+template KEY_F*(n: expr): expr = KEY_F0 + n
 
 template COLOR_PAIR*(n: expr): expr = 
-  ((cast[cunsignedlong]((n)) shl COLOR_SHIFT) and A_COLOR)
+  ((cunsignedlong(n) shl COLOR_SHIFT) and A_COLOR)
 
 template PAIR_NUMBER*(n: expr): expr = 
   (((n) and A_COLOR) shr COLOR_SHIFT)
diff --git a/lib/wrappers/readline/readline.nim b/lib/wrappers/readline/readline.nim
index 1f0dd564f..bbe416534 100644
--- a/lib/wrappers/readline/readline.nim
+++ b/lib/wrappers/readline/readline.nim
@@ -29,8 +29,8 @@ elif defined(macosx):
 else: 
   const 
     readlineDll* = "libreadline.so.6(|.0)"
-##  mangle "'TCommandFunc'" TCommandFunc
-##  mangle TvcpFunc TvcpFunc
+#  mangle "'TCommandFunc'" TCommandFunc
+#  mangle TvcpFunc TvcpFunc
 
 import rltypedefs
 
diff --git a/lib/wrappers/sqlite3.nim b/lib/wrappers/sqlite3.nim
index 586f763ae..7b7f0874e 100644
--- a/lib/wrappers/sqlite3.nim
+++ b/lib/wrappers/sqlite3.nim
@@ -106,15 +106,15 @@ type
   Pstmt* = ptr Tstmt
   Tvalue{.pure, final.} = object 
   Pvalue* = ptr Tvalue
-  PPValue* = ptr Pvalue 
+  PValueArg* = array[0..127, Pvalue]
   
   Tcallback* = proc (para1: pointer, para2: int32, para3, 
                      para4: cstringArray): int32{.cdecl.}
   Tbind_destructor_func* = proc (para1: pointer){.cdecl.}
   Tcreate_function_step_func* = proc (para1: Pcontext, para2: int32, 
-                                      para3: PPValue){.cdecl.}
+                                      para3: PValueArg){.cdecl.}
   Tcreate_function_func_func* = proc (para1: Pcontext, para2: int32, 
-                                      para3: PPValue){.cdecl.}
+                                      para3: PValueArg){.cdecl.}
   Tcreate_function_final_func* = proc (para1: Pcontext){.cdecl.}
   Tresult_func* = proc (para1: pointer){.cdecl.}
   Tcreate_collation_func* = proc (para1: pointer, para2: int32, para3: pointer,