工作中使用平台呼叫總結

2021-06-29 03:04:31 字數 1908 閱讀 8048

1、託管**向非託管**傳遞字串

非託管api:

extern "c" __declspec(dllexport)

int_cdeclwritedatatofcsfile(char* filepath);

託管:

[dllimport

(_business.dll, entrypoint = 

"writedatatofcsfile"

, callingconvention = 

callingconvention

.cdecl)]

public

extern

static

bool

writefcs(

string

filepath,

string

samplelabel); 

2、託管**向非託管**傳送陣列

非託管api:

extern "c" __declspec(dllexport)

int_cdecl sendcommand(short comcode,shortdstcode,short srccode,floatparam,int nsize);

託管:[dllimport(_dllname,entrypoint ="sendcommand",callingconvention =callingconvention.cdecl)]

public

static

extern

int sendcommand(

short cmdcode,

short dstdevicecode,

shortsrcdevicecode,

float params,

int nsize); 

3、非託管**通過引數向託管**傳遞一般型別值和陣列

非託管api:

extern

"c"__declspec

(dllexport)

int_cdeclgetharddeviceinfo(short* order,float** ordercontent,int*nsize);//引數1返回短整型值,引數2返回浮點型陣列,引數3返回整形值,該值表示引數2陣列大小

託管:[dllimport(_dllname,entrypoint ="getharddeviceinfo",callingconvention=callingconvention.cdecl)]

public

static

extern

boolgetresponse(

refshortresponsecode,

outintptrparameters,

refintnsize); 

//需要將資料從非託管記憶體指標複製到託管字元陣列,關鍵**如下:

if (nsize >= 0)

4、非託管**通過返回值想託管**傳遞陣列

非託管api:

extern

"c"__declspec(

dllexport)

int*

_cdecl getthearray(

int*nsize);

託管:[dllimport(_dllname,entrypoint ="getthearray",callingconvention =callingconvention.cdecl)]

unsafe

public

static

extern

int* getthearray(ref

int nsize);

使用方法舉例:

unsafe

} }

django logger(工作中使用)

1 setting.py 注意 建立log資料夾 存放log的目錄 logging dir os.path.join base dir,log logging verbose standard handlers 用來定義具體處理日誌的方式,可以定義多種,default 就是預設方式,console ...

工作中使用docker筆記

docker compose.yml檔案配置 docker compose命令介紹 docker compose up 建立容器時報錯 docker compose up error encountered errors while bringing up the project.錯誤及解決方式在經...

工作中使用過的git 命令總結

檢視提交歷史記錄和某個記錄的修改詳情 1 git log 2 git show 1f2e6d6ae0bcbde88fc4b8409e5f4ceb1882f4de 檢視某個檔案的提交歷史記錄和某個記錄的修改詳情 1 git log pretty oneline git log pretty oneli...