pb呼叫SHFileOperation出錯的問題

2021-08-22 20:23:29 字數 1615 閱讀 8332

pb11裡直接按網上的寫法。執行是有ok有錯誤。還是pfrom和pto末尾需要兩個null字元的問題。本想在string後面直接加兩個字元,也是不行(因為字串後面你加再多的"\0"都不起作用,null本來就是字串的結束符--我是這樣理解的)。後面看到blob的例子。方才搞定。看來對資料塊的引用傳遞時,還是blob好。另外記得encodingansi!

宣告:function long shfileoperation(ref shfileopstruct lpfileop) library "shell32.dll" alias for "shfileoperationa;ansi"

//變數

private constant int fo_move = 1 // &h1

private constant int fo_copy = 2 //&h2

private constant int fo_delete =3 //&h3

private constant int fo_rename =4 //&h4

private constant int fof_noconfirmation =16 //&h10

private constant int fof_silent = 4 //&h4

private constant int fof_noerrorui = 1024 //&h400

//stru

type shfileopstruct from structure

ulong hwnd

ulong wfunc

blob pfrom

blob pto

//func

//public function long of_rename_file (long lfrmhwnd, string sfrom, string sto, boolean fshowprogress)

shfileopstruct udtpath

udtpath.hwnd = lfrmhwnd

udtpath.wfunc = fo_rename

udtpath.pfrom = blob(sfrom,encodingansi!) + blob(char(0),encodingansi!) + blob(char(0),encodingansi!)

udtpath.pto = blob(sto,encodingansi!) + blob(char(0),encodingansi!) + blob(char(0),encodingansi!)

long ll_bitvalues

ll_bitvalues[1] = fof_noconfirmation

ll_bitvalues[2] = fof_noerrorui

if fshowprogress then

ll_bitvalues[3] = 0

else

ll_bitvalues[3] = fof_silent

end if

udtpath.fflags = gf_bit_or(ll_bitvalues)

return shfileoperation(udtpath)

備忘 PB呼叫c dll

最近因為專案需要將某演算法封裝為dll以供pb呼叫,其間出現了某些某些問題,先將其一一記錄。最開始封裝好的dll,c 能夠呼叫,但pb呼叫時卻報錯。通過查閱資料得知,pb呼叫的dll中,需要以 stdcall來宣告外部介面,且需要編寫.def檔案。因為vc 對於 declspec dllexport...

pb如何呼叫儲存過程

create or replace procedure testadd id in number,name in varchar2 is begin insert into leadtest id,name values id,name end testadd long lngid string s...

PB呼叫動態SQL語句

轉截自 原文解釋的比較詳細 本文只做以後用到的時候方便查詢 第一種 這種型別的動態sql語句經常用來執行ddl或者資料庫專用的其他sql語句。語法格式是 execute immediate sqlstatement 其中sqlstatement是個字串,其內容是有效的sql語句 transactio...