# Using win32api

**URL:** <https://www.ruby-forum.com/t/using-win32api/140924>\
**Category:** Ruby\
**Created:** [June 19, 2008, 9:14pm UTC](https://www.ruby-forum.com/t/using-win32api/140924 "2008-06-19T21:14:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tristincolby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/58f4c7/32.png) [@tristincolby](https://www.ruby-forum.com/u/tristincolby)\
**Post date:** [June 19, 2008, 9:14pm UTC](https://www.ruby-forum.com/t/using-win32api/140924/1 "2008-06-19T21:14:18Z")

</div>

Can anyone point me in the right direction for some good, in depth  
examples  
of using Win32API. I"m extremely lost when it comes to  
packing/unpacking  
the data. After many many searches, I find several places where memcpy  
is  
being used and others where DL is also being used. Other places it  
doesn’t  
look necessary. Here’s the specific function i’m trying to hook into

DWORD WNetAddConnection2(  
\_\_in LPNETRESOURCE _lpNetResource_, ← NETRESOURCE Structure  
\_\_in LPCTSTR _lpPassword_,  
\_\_in LPCTSTR _lpUsername_,  
\_\_in DWORD _dwFlags_  
);

> **[WNetAddConnection2A function (winnetwk.h) - Win32 apps](https://learn.microsoft.com/en-us/windows/win32/api/winnetwk/nf-winnetwk-wnetaddconnection2a?redirectedfrom=MSDN)**
>
> The WNetAddConnection2 function makes a connection to a network resource and can redirect a local device to the network resource. (ANSI)

The packing of the structure is what is giving me the most confusion.  
Here’s what I have so far.
