Coder Social home page Coder Social logo

win32cr's Introduction

win32cr

CI Crystal Latest CI

Win32 library bindings created from Windows Metadata.

Installation

Add this to your application's shard.yml:

dependencies:
  win32cr:
    github: mjblack/win32cr

Usage

require "win32cr"
require "win32cr/ui/windowsandmessaging"

LibWin32.MessageBoxW(nil, "Message Box Body".to_utf16, "Title".to_utf16, LibWin32::MESSAGEBOX_STYLE::MB_OK)

Contributing

  1. Fork it (https://github.com/mjblack/win32cr/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

win32cr's People

Contributors

mjblack avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

lachlan

win32cr's Issues

Error: already initialized constant LibWin32::IID_IXmlReader

In src\win32cr\data\xml\xmllite.cr:206:3

 206 | IID_IXmlReader = LibC::GUID.new(0x7279fc81_u32, 0x709d_u16, 0x4095_u16, StaticArray[0xb6_u8, 0x3d_u8, 0x69_u8, 0xfe_u8, 0x4b_u8, 0xd_u8, 0x90_u8, 0x30_u8])
       ^-------------
Error: already initialized constant LibWin32::IID_IXmlReader

Unable to get result from an IFileOpenDialog's IShellItem#get_display_name

require "win32cr"
require "win32cr/system/com"

LibWin32.CoInitializeEx(nil, LibWin32::COINIT::COINIT_APARTMENTTHREADED | LibWin32::COINIT::COINIT_DISABLE_OLE1DDE)

begin
  com = ComPtr(LibWin32::IFileOpenDialog).new(LibWin32::CLSID_FileOpenDialog, LibWin32::IID_IFileOpenDialog)
  default_flags = 0_u32
  com.get_options(pointerof(default_flags))
  com.set_options((default_flags | LibWin32::FILEOPENDIALOGOPTIONS::FOS_PATHMUSTEXIST.to_i | LibWin32::FILEOPENDIALOGOPTIONS::FOS_PICKFOLDERS.to_i))
  com.show(Pointer(Void).null)

  item = LibWin32::IShellItem.new
  buffer = uninitialized UInt16*
  if com.get_folder(pointerof(item))
    result = item.get_display_name(pointerof(item), LibWin32::SIGDN::SIGDN_FILESYSPATH, pointerof(buffer))
    pp result #String.from_utf16(buffer)
    # pp String.from_utf16(buffer)[0]
  else
    puts "Failed."
  end
rescue e
  puts e.message
end

LibWin32.CoUninitialize
Invalid memory access (C0000005) at address 0x7fffe5785de8
[0x7fffe5785de8] ShellExecuteExW +759464 in C:\Windows\SYSTEM32\windows.storage.dll
[0x7ff6a8c50cc1] get_display_name at C:\Users\cyber\Code\w3dhub_packager_webview\lib\win32cr\src\win32cr\ui\shell.cr:17422
[0x7ff6a8b8177e] __crystal_main at C:\Users\cyber\Code\w3dhub_packager_webview\src\w3dhub_packager.cr:16
[0x7ff6a8c57569] main_user_code at C:\Users\cyber\Applications\crystal-1.12.1\src\crystal\main.cr:129
[0x7ff6a8c5748a] main at C:\Users\cyber\Applications\crystal-1.12.1\src\crystal\main.cr:115
[0x7ff6a8bcf449] main at C:\Users\cyber\Applications\crystal-1.12.1\src\crystal\main.cr:141
[0x7ff6a8bcf563] wmain at C:\Users\cyber\Applications\crystal-1.12.1\src\crystal\system\win32\wmain.cr:37
[0x7ff6a8c58da0] __scrt_common_main_seh at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
[0x7fffe7cb7344] BaseThreadInitThunk +20 in C:\Windows\System32\KERNEL32.DLL
[0x7fffe9ae26b1] RtlUserThreadStart +33 in C:\Windows\SYSTEM32\ntdll.dll

Function being used:
https://github.com/mjblack/win32cr/blob/c4da22cfbe3bf363bf7ef5af1c00408f6626ce42/src/win32cr/ui/shell.cr#L17421-L17423

  def get_display_name(this : IShellItem*, sigdnname : SIGDN, ppszname : LibC::LPWSTR*) : HRESULT
    @lpVtbl.value.get_display_name.call(this, sigdnname, ppszname)
  end

*it is midnight, so I may be missing something obvious...

Duplicate C fun definitions

Recent changes to Crystal source code has implemented win32 library functions that are present in this library.

Those C library functions are

  • CreateDirectoryW
  • SetFilePointerEx

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.