GithubHelp home page GithubHelp logo

annih / windows-api Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cosmo0920/windows-api

0.0 2.0 0.0 114 KB

A wrapper for win32-api that simplifies and automates common idioms

Ruby 100.00%

windows-api's Introduction

== Description
   This is a wrapper for Win32::API that simplifies various idioms typically
   used by people who use Win32::API.

== Synopsis
   require 'windows/api'
   include Windows
   
   # Defaults to 'V' prototype, 'L' return type and 'kernel32' library
   GetVersion = API.new('GetVersion')
   
   # Defaults to 'L' return type and 'kernel32' library
   CloseHandle = API.new('CloseHandle', 'L')
   
   # Defaults to 'kernel32' library
   GetWindowsDirectory = API.new('GetWindowsDirectory', 'LI', 'I')
   
   # Explicitly state every argument
   GetComputerNameEx = API.new('GetComputerNameEx', 'PPP', 'I', 'kernel32')
   
   # Use long data type names
   GetUserName = API.new('GetUserName',['LPTSTR','LPDWORD'],'BOOL','advapi32')
   
   # Attributes for possible inspection
   puts GetVersion.dll_name      # 'kernel32'
   puts GetVersion.function_name # 'GetVersion'
   puts GetVersion.prototype     # ['V']
   puts GetVersion.return_type   # 'L'

   # Automatic method generation

   # This code....
   module Windows
     module Foo
       API.auto_namespace = 'Windows::Foo'
       API.auto_constant  = true
       API.auto_method    = true
       API.auto_unicode   = true
         
       API.new('GetComputerName', 'PP', 'B')
     end
   end

   # Is the same as this code...
   module Windows
     module Foo
       GetComputerName  = Win32API.new('kernel32', 'GetComputerName', 'PP', 'I')
       GetComputerNameA = Win32API.new('kernel32', 'GetComputerNameA', 'PP', 'I')
       GetComputerNameW = Win32API.new('kernel32', 'GetComputerNameW', 'PP', 'I')

       def GetComputerName(p1, p2)
         GetComputerName.call(p1, p2) != 0
       end

       def GetComputerNameA(p1, p2)
         GetComputerName.call(p1, p2) != 0
       end

       def GetComputerNameW(p1, p2)
         GetComputerName.call(p1, p2) != 0
       end
     end
   end

== Advantages over plain Win32::API
   * Automatic constant generation.
   * Automatic definition of ANSI and Unicode method wrappers, including
     special handling for boolean methods.
   * Ability to use more familiar Windows data types, e.g. DWORD.
   * Automatic handling of msvcrt vs msvcrXX via MSVCRT_DLL constant.

== Other Stuff
   There's also a WideString class for easily creating wide strings for
   Ruby 1.8.x. Ruby 1.9.x can use Ruby's encoding methods to accomplish
   the same effect, however.

== More documentation
   See the RDoc documentation, which should have been automatically generated
   if you installed this as a gem.

== Future Plans
   This library will eventually be dropped in favor of FFI once I'm convinced
   that FFI is stable for both mingw and mswin.

== Bugs
   None that I'm aware of. Please submit any bugs to the project page at
   https://github.com/djberg96/windows-api.

== Copyright
   (C) 2007-2014, Daniel J. Berger

== License
   Artistic 2.0

== Author
   Daniel Berger

windows-api's People

Contributors

annih avatar cameroncox avatar djberg96 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.