Re: How do I convert this to Euphoria?

new topic     » goto parent     » topic index » view thread      » older message » newer message
bugmagnet said...

'http://vb.mvps.org/samples/project.asp?id=console 
Private Declare Function GetStdOutHandle Lib "kernel32" _ 
        Alias "GetStdHandle" _ 
       (Optional ByVal HandleType As Long = -11) As Long 
 
Private Declare Function WriteFile Lib "kernel32" _ 
       (ByVal hFile As Long, _ 
        ByVal lpBuffer As String, _ 
        ByVal cToWrite As Long, _ 
        ByRef cWritten As Long, _ 
        Optional ByVal lpOverlapped As Long) As Long 

I think I've figured out GetStdHandle, but WriteFile is still proving difficult. What's the declaration for this?

Kind regards,
Bugmagnet

Untested code below.

To define:

define_c_func(open_dll("kernel32.dll"), "GetStdOutHandle", {C_LONG}, C_LONG) 
 
define_c_func(open_dll("kernel32.dll"), "WriteFile", {C_LONG, C_POINTER, C_LONG, C_POINTER, C_LONG}, C_LONG) 

To use:

atom handle = c_func(GetStdOutHandle_, {-11}) 
 
atom str = allocate_string(your_text) 
atom byref = allocate(4) -- or allocate(8) on 64bit if using pre-alpha 4.1.0 
poke4(byref, 0) -- or poke8 if ... 
 
atom ret = c_func(WriteFile_, {handle, str, length(your_text), byref, 0}) 
free({str, byref}) 

EDIT: change empty string to str

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu