jjzjj

javascript - 如何使用 js-ctypes Firefox 扩展调用 native C 代码?

我正在尝试构建一个需要调用nativeC代码的Firefox扩展。我的C程序代码是:#includeintadd(inta,intb){return(a+b);}我的JavaScript代码是:var{Cu}=require('chrome');varself=require('sdk/self');Cu.import("resource://gre/modules/ctypes.jsm");varlib;varputs;lib=ctypes.open('G:\\Shankar\\Project\\Maidsafe\\Firefox\\addon-sdk-1.17\\jsctype_s

go - 如何将 *_Ctype_char 转换为 *_Ctype_uchar

我正在使用cgo调用动态库中的函数,其签名如下所示:intdecompress(int,constuint8_t*,size_t,uint8_t*,size_t);这是我的代码://#includestatementshereimport"C"import("unsafe")funcDecompress(comp_typeint,datastring,expected_sizeint)[]byte{compressedData:=C.CString(data)deferC.free(unsafe.Pointer(compressedData))compressedDataSize:=C

python - 在 Google App Engine 中使用 ctypes 来使用二进制文件?

我试图在GoLang和Python之间建立接口(interface)。我长期以来一直是Python的粉丝,并且喜欢使用它。但随着时间的推移,我发现它对进行计算等非常不利。尤其是当可能涉及大型数据集时。我开始学习golang主要是因为它的速度,并考虑在我的应用程序中将其用作库。在GoLang中编写密集代码,然后使用Python库中的方法在Python中编写漂亮的高级应用程序代码。完成第一个原型(prototype)后,我在GAE中部署了我的代码。不幸的是我撞到了这个fromctypesimport*File"/base/alloc/tmpfs/dynamic_runtimes/pytho

javascript - js-ctypes 无效参数

我正在尝试在Firefox中使用js-ctypes运行winscard函数。我有工作的C代码,我开始将代码复制到javascipt。不幸的是,我的第一个函数-SCardEstablishContext返回以下错误:SCARD_E_INVALID_PARAMETER0x80100004参数有什么问题?Components.utils.import("resource://gre/modules/ctypes.jsm");constNULL=ctypes.voidptr_t(0);varcardLib=ctypes.open("C:\\WINDOWS\\system32\\WinSCard

python - ctypes:使用 lib.so(在 Mac 上)时指针地址修改,但在使用 lib.dll(在 Windows 上)时不修改

来源C++/***typedefineclasstemplateforextern"C"***/typedefMpolyMpolyDouble;//Declarefunctionsasextern"C"forctypes////>>compilerstatement(mac/linux):g++-shared-olibPoly.so-fPIClibPoly.cpp//>>compilerstatement(windows):g++-shared-olibPoly.dlllibPoly.cpp//extern"C"{/***libPolyConstructor/DestructorRou

python - : Python, ctypes.windll.user32.SystemParametersInfoA 中的参数是什么?

20、0和3在Python函数中的含义:SPI_SETDESKWALLPAPER=20ctypes.windll.user32.SystemParametersInfoA(SPI_SETDESKWALLPAPER,0,'imgpath',3)我很新,还没有找到任何有用的信息。另外,我可以定义墙纸的行为方式,例如拉伸(stretch)、平铺或居中吗? 最佳答案 SystemParametersInfoA函数是一个直接的Windows界面。它是一个C接口(interface),在本例中我们从Python调用它。但它的结构是这样的,因为它

python - ctypes MessageBoxW 返回意外的中文字符

我使用以下代码来显示弹出消息ifplatform.system()=='Windows':importctypesdefmessage_box(title,text,style):returnctypes.windll.user32.MessageBoxW(0,text,title,style)ifplatform.system()=='Windows':message_box('Error','PhatsinhloiUnicode,kiemtrachitiettrong%s'%common.ERR_LOG_FILE,0)当我的应用程序在Windows7中运行时,弹出窗口包含所有意外的

python ctype初始化一个结构

我的结构包含所有unsignedchar元素typedefstruct{unsignedcharbE;unsignedcharcH;unsignedcharcL;unsignedcharEId1;unsignedcharEId0;unsignedcharSId1;unsignedcharSId0;unsignedcharDLC;unsignedcharD0;unsignedcharD1;unsignedcharD2;unsignedcharD3;unsignedcharD4;unsignedcharD5;unsignedcharD6;unsignedcharD7;}CMsg;下面的函数

python - ctypes dll 调用在 ipython 中有效,但在常规 python 中无效

注意:我最初的问题因题外话而被关闭,但我将重新提交此问题并为任何可能遇到类似问题的人提供答案我的系统详细信息:Windows1064-bitPython3.664-bit不幸的是,由于保密原因,我无法共享数据文件或dll,但我正在使用供应商提供的dll(用Delphi编写)来读取二进制仪器数据文件。我也无权访问源代码,也无权获得详细的编码支持。下面显示了一个名为filereadtest.py的示例脚本。importctypesbinary_file=r"C:\path\to\binaryfile"dll_file=r"C:\path\to\dll.dll"dll=ctypes.WinD

python - 为什么我需要 __declspec(dllexport) 来使某些函数可以从 ctypes 访问?

所以我正在学习使用Pythonctypes模块。这是我在Windows上使用gcc-shared(4.8版)编译的简单C文件,以获取示例.dll:#includeintaddition(inta,intb){returna+b;}我现在可以像这样从Python访问它:>>>fromctypesimport*>>>mylibc=CDLL(r"somepath\mysample.dll")>>>mylibc.addition>>>mylibc.addition(2,3)5现在我尝试对包含此函数的不同的、更大的和更复杂的.c文件做同样的事情:__declspec(dllexport)void