c++ - how to pinvoke SLGetWindowsInformation from c# -
i know how pinvoke data structure given in function giving me more troubles figure out on own
function name slgetwindowsinformation exists @ slc.dll
hresult winapi slgetwindowsinformation( _in_ pcwstr pwszvaluename, _out_opt_ sldatatype *pedatatype, _out_ uint *pcbvalue, _out_ pbyte *ppbvalue );
for full reference here
thanks in advance , have wonderful day
like this:
enum sldatatype { sl_data_none = reg_none, sl_data_sz = reg_sz, sl_data_dword = reg_dword, sl_data_binary = reg_binary, sl_data_multi_sz = reg_multi_sz, sl_data_sum = 100 }; // can values of reg_xxx constants windows header files [dllimport("slc.dll", charset = charset.unicode)] static extern uint slgetwindowsinformation( string valuename, out sldatatype datatype, out uint cbvalue, out intptr value );
call function this:
sldatatype datatype; uint cbvalue; intptr valueptr; uint res = slgetwindowsinformation(valuename, out datatype, out cbvalue, out valueptr); // check res indicates success before proceeding byte[] value = new byte[cbvalue]; marshal.copy(valueptr, value, 0, value.length); marshal.freehglobal(valueptr);
note may seem little confusing, marshal.freehglobal
calls localfree
, correct way deallocate buffer.
Comments
Post a Comment