vc看存儲
⑴ VC怎麼判斷文件存儲是否成功或者說是否結束
如果文件存儲是自己寫的,存儲函數的結束是自己控制的,顯而易見。
如果文件存儲是其它進程乾的稿襪事情,不是自己寫的,採用獨占方式打開存儲文件伏吵, HANDLE hFile = CreateFile(szDesFile,GENERIC_READ,NULL,NULL,OPEN_EXISTING,NULL,NULL);
if(hFile==INVALID_HANDLE_VALUE) {GetLastError()...} 失敗則表示正被其它缺敬侍進程訪問。
⑵ 在VC++6.0中,如何查看變數的內存地址請詳細說明操作步驟。順便也告訴我如何查看庫函數
第一:用printf("宏或%d"扮絕慎, &變數名);輸出地址的整數值
第二:用調試工具,調試時,就可以看廳敬到的
庫函數就在vc安裝目錄下,lib目錄中
⑶ VC++ 怎麼看一個變數存儲在棧中還是堆中
堆和棧中的變數名稱余薯沒有區別,其區別在於出生(產生)和死亡的方式及其;
a在堆中
b在棧中
a是通過new的方法從堆內存區中動態分配的,程序結束是需要手動去銷毀它,否則就豎睜者一直早襲佔用那一塊內存而無法回收,隨著程序的多次運行,無法回收的內存越來越多,就是內存泄露問題,當然重新啟動就沒有事了!
b不是動態分配的,佔用的棧空間,在程序結束時,自動銷毀!
只需考慮:動態分配就在堆區,其他都不在堆區
⑷ VC++獲取資料庫 存儲過程中return value的值 函數的調用過程是怎麼樣的
(1)執行一個沒有參數的存儲過程的代碼如下:
SqlConnection
conn=new
SqlConnection(「connectionString」);
SqlDataAdapter
da
=
new
SqlDataAdapter();
da.selectCommand
=
new
SqlCommand();
da.selectCommand.Connection
=
conn;
da.selectCommand.CommandText
=
"NameOfProcere";
da.selectCommand.CommandType
=
CommandType.StoredProcere;
(2)執行一個有參數的存儲過程的代碼如下
SqlConnection
conn=new
SqlConnection(「connectionString」);
SqlDataAdapter
da
=
new
SqlDataAdapter();
da.selectCommand
=
new
SqlCommand();
da.selectCommand.Connection
=
conn;
da.selectCommand.CommandText
=
"NameOfProcere";
da.selectCommand.CommandType
=
CommandType.StoredProcere;
param
=
new
SqlParameter("@ParameterName",
SqlDbType.DateTime);
param.Direction
=
ParameterDirection.Input;
param.Value
=
Convert.ToDateTime(inputdate);
da.selectCommand.Parameters.Add(param);
若需要添加輸出參數:
param
=
new
SqlParameter("@ParameterName",
SqlDbType.DateTime);
param.Direction
=
ParameterDirection.Output;
param.Value
=
Convert.ToDateTime(inputdate);
da.selectCommand.Parameters.Add(param);
若要獲得參儲過程的返回值:
param
=
new
SqlParameter("@ParameterName",
SqlDbType.DateTime);
param.Direction
=
ParameterDirection.ReturnValue;
param.Value
=
Convert.ToDateTime(inputdate);
da.selectCommand.Parameters.Add(param);