[Win32utils-devel] strcpy declaration

Daniel Berger djberg96 at gmail.com
Wed Aug 24 22:52:09 EDT 2011

In windows-pr strcpy is declared with a prototype of "PL". However, I can't
make that work:

require 'win32/api'
include Win32

Strcpy_p = Win32::API.new('strcpy', 'PP', 'L', 'msvcrt')
Strcpy_l = Win32::API.new('strcpy', 'PL', 'L', 'msvcrt')

buf = 0.chr * 4
str = "hello"

Strcpy_p.call(buf, str) # works
p buf

buf = 0.chr * 4
str = "hello"

Strcpy_l.call(buf, str.unpack('L').first) # fails, segfault
p buf

I would think either declaration would work but apparently not.

Have we simply not been using this function all this time?



More information about the win32utils-devel mailing list