[R] Use of C functions inside the DLL object

Cleber N.Borges klebyn @ending from y@hoo@com@br
Mon Nov 19 21:57:09 CET 2018


hello everybody and good night ...
I'm trying to learn how to use a DLL, via "dyn.load" and ".C" inside the R.
I did some testing (below is a part of what I tried) and I could not 
figure out how to do this.
If anyone can give a hint on how to do this manipulation, it would be a 
lot of help!
And thanks in advance for any tip.
Thank you!
Cleber

###

In the pdf explaining the SDK, it has function detail:

FDwfGetVersion(char szVersion[32])
Description: Retrieves the version string. The version string is 
composed of major, minor, and build numbers (i.e.,
“2.0.19”).


##############################################################

### In R, I tried:

 > dwf <- dyn.load("C:\\Windows\\System32\\dwf")
 > is.loaded("FDwfGetVersion")
[1] TRUE
 > result <- .C("FDwfGetVersion", version=as.character() )
 > result
$`version`
character(0)

 > str(result)
List of 1
  $ version: chr(0)

#################################

But in Python, I saw that the result is as follows (examples in Python 
are made available by the manufacturer)

#################################

 >>> from ctypes import *
 >>> dwf = cdll.dwf
 >>> version = create_string_buffer(16)
 >>> dwf.FDwfGetVersion(version)
1
 >>> print("DWF Version: "+str(version.value))
DWF Version: 3.8.22
 >>>








---
Este email foi escaneado pelo Avast antivírus.
https://www.avast.com/antivirus


More information about the R-help mailing list