Jiangsheng的CSDN Digest (Jan 7 2006)

CSDN 討論總結系列:


可以讓TWebBrowser只下載代碼而不執行嗎(Delphi 網絡通信/分佈式開發)


在用WebBrowser.Navigate打開一個網頁後可否只讓其下載網頁的代碼,而不執行並顯示出來啊,要保證能用(WebBrowser.Document as IHTMLDocument2)調用網頁的元素哦


不想顯示網頁,可以讓WebBrowser1範圍儘量小,放在按鈕後就可以了。雖然這樣看不到網頁的顯示了,但網頁中的JS腳本還是會執行,有些還彈出廣告窗口。只需要下載文件的話可以用URLDownloadToFile
只需要分析的話可以參考http://www.euromind.com/iedelphi/uilessparser.htm
也可以集成一個瀏覽器控件,在容器中處理DISPID_AMBIENT_DLCONTROL調用,返回DLCTL_DOWNLOADONLY標誌,參考http://www.euromind.com/iedelphi/embeddedwb.htm。


遞歸開線程疑問(VC/MFC 進程/線程/DLL )


我用遞歸開線程,用下面的方法輸出錯誤信息,結果是一堆“not enough space”錯誤
if(_beginthread(find_combination,0,(void*)p_my_data) == -1)
{
printf("strerror says open failed: %s/n", strerror(errno));
return;
}
問問,window裏面一個進程理論上能開多少線程?


一個線程的開銷包括:
內核模式下的開銷(內核堆棧,對象管理所需內存)
用戶模式下的開銷(線程局部存儲、線程環境塊、堆棧、CRT、MFC、COM等等等等)

通常,線程數目的瓶頸在於線程自己的堆棧。Visual C++編譯器默認設置是每個線程的堆棧大小是1兆。當然,如果你在創建線程時指定較小的堆棧大小,你應該可以創建較多的線程。

但是創建大量線程不是一個好的設計。每個線程創建和銷燬的時候,Windows會調用已經加載的動態鏈接庫的DLLMain,傳遞DLL_THREAD_ATTACH和DLL_THREAD_DETACH作爲參數,除非動態庫使用DisableThreadLibraryCalls禁用了這個通知。在創建大量線程的時候,這個開銷是很大的。對於你這樣的用後即棄的線程,你應該使用線程池。一個線程池示例可以在微軟知識庫找到(http://support.microsoft.com/support/kb/articles/Q197/7/28.asp)。


用 DirectShow 怎樣生成 asf / wmv 的文件(VC/MFC 圖形處理/算法)


graph 不能 run , 是不是 Asf Writer filter 的屬性設置不對或不全 ?


DSCopy (DirectShow) Transcodes one or more files to an ASF file using the DirectShow® WM ASF Writer filter. The input file may be any compressed or uncompressed format supported by DirectShow.

DSPlay (DirectShow) This sample is an interactive audio/video media file player with DRM support. It uses DirectShow's WM ASF Reader filter to play Windows Media files (ASF, WMA, WMV) without DRM protection and files which use DRM at a level of 100 or below. See readme.txt in the sample's directory for more information.

DSSeekFm (DirectShow) This sample demonstrates how to use the DirectShow WM ASF Reader Filter to play ASF content in a DirectShow filter graph, and also how to use the frame seeking support in the Windows Media Format SDK.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmform95/htm/sampleapplications.asp
 


如何讀取xml的version等信息(VC/MFC HTML/XML )


如何讀取xml的version等信息

我想知道怎麼用MSXML,讀取一個xml文件的processing instruction

即<?xml version="1.0"?>中的version等信息的值

這些信息可以用createProcessingInstruction來寫,爲什麼找不到讀取的方法


That particular line of your file isn't part of the resulting DOM after
you parse the document. But the XML version and encoding used should
be. If I read correctly, the version and encoding strings there will be
available in DOM version 3, which is not currently implemented fully to
my knowledge by any XML parser. However, if you're using Xerces, it has
methods in the Document interface for retrieving those -- and the API
clearly states that it's experimental.

http://groups.google.com/group/comp.text.xml/browse_frm/thread/85c1481c1b0763f0/c2506bd9ce7742b9?lnk=st&q=read+xml+version&rnum=11&hl=en#c2506bd9ce7742b9


一塊很古老的板卡,有驅動源程序*.asm,現在怎樣用vc++編譯這個驅動以及怎麼在接下來的程序中調用呢?(其他開發語言 彙編語言 )


以前一個師兄用borlandC++4.0編寫了一個程序,只有源程序了,我怎麼編譯也編譯不出來,可能是windows版本的問題(據說可能只有windows3.1之流能夠很好的兼容,我用xp裝borlandC++4.0就痛苦了好長時間(用兼容方式裝成功),但是編譯怎麼也通不過),所以現在我想重新寫這個程序,完成了一點點,碰到一個嚴重問題:板卡的驅動問題,那個師兄留下了兩個*.asm文件,就是板卡的驅動,但是怎麼用VC++裏面編譯,並可以運行這兩個*.asm文件呢?以及接下來怎樣在程序中進行調用呢?

我以前的師兄是這樣使用的:
void far dacs(int ch,int Data);
int far adcs(int Data,int ch);
也就是ad/da卡。
然後再直接調用dacs(int ch,int data)和adcs(int data,int ch)函數就可以了,但是怎麼將*.obj或者*.exe文件包括進去呢?


 newstm error LNK2019: unresolved external symbol _adcs referenced in function "public: int __thiscall motorDialog::gostep(void)" (?gostep@motorDialog@@QAEHXZ)
newstm fatal error LNK1120: 1 unresolved externals


How to use the Development Studio or Visual Workbench with MASM
http://support.microsoft.com/kb/q106399/

估計你這兩個.asm還是16-bit的代碼,
首先需要改成32-bit兼容的。
然後用masm或者tasm彙編成objs,加入到工程中,
然後在程序中加入外部引用(在.cpp或者.h中都可以):
extern "c" void far dacs(int ch,int Data);
extern "c" int far adcs(int Data,int ch);
另外可能調用約定也要改成.model flat,之後所有訪問內存的代碼都要改用flat模式,因爲16-bit Windows的默認調用約定是Pascal。
你先看看.asm中的實現是按什麼順序處理參數、是否自己清除棧框架。你要把函數聲明爲公用的。一些彙編器默認將所有函數編譯成私有的。把生成的obj文件加入到工程(從文件夾拖到file view)。


ATL的線程函數中 FIRE EVENT出錯,其它類中FIRE EVENT 就OK ?(VC/MFC 進程/線程/DLL )


ATL和MFC都不是線程安全的
參考http://www.mvps.org/vcfaq/com/11.htm


以不同身份登陸域以獲取不同的服務權限 (C++ Builder 基礎類)


如何可以做到不轉換Windows用戶的情況下,以另一個用戶的身份訪問域服務器,並且結束時可以註銷該用戶身份。
參看了一些資料,可能要用到LogonUser,DuplicateTokenEx,CreateProcessAsUser這些函數


你可以用CreateProcessAsUser函數另外啓動一個進程,之後使用進程間通訊(http://msdn.microsoft.com/library/en-us/ipc/base/interprocess_communications.asp )的方法來控制啓動的程序。

參見http://www.xfocus.net/articles/200504/795.html

用LogonUser、CreateProcessAsUser,要SE_TCB_NAME權限,且即使你是administrator,也很難在程序中得到要SE_TCB_NAME權限。你可以在控制面板->管理工具->本地安全設置->用戶權利指派中將"以操作系統方式運行"賦給你要設SE_TCB_NAME權限的用戶,這樣你上面的程序應該可以運行,但有安全隱患,因爲SE_TCB_NAME是系統的最高權限。

建議用CreateProcessWithLogon。這需要本地登陸權限

void __fastcall TForm1::Button1Click(TObject *Sender)
{
STARTUPINFOW si;
PROCESS_INFORMATION pi;
memset(&si,0,sizeof(si));
si.cb=sizeof(si);

CreateProcessWithLogonW(L"yourusername",L"yourdomain",L"yourpassword",LOGON_WITH_PROFILE,L"cmd.exe",NULL,CREATE_DEFAULT_ERROR_MODE,
NULL,NULL,&si,&pi);
}
 

或用命令行的runas,
如:
runas /env /user:[email protected] "notepad /"my file.txt/""


分發軟件時,需要將msvcr71.dll複製到system32目錄下(Delphi 非技術區)


可是這個文件有可能已存在,也有可能該文件存在別的目錄下正在被使用


http://support.microsoft.com/default.aspx?scid=kb;en-us;326922


inet控件下載ftp文件後,下載的文件被存放在IE緩存文件夾中,如何自動清除(VB 基礎類 )


找到緩存文件夾,清空裏面的文件即可

Private Sub Command2_Click()
'需要引用Microsoft Shell Controls And Automation
Dim mShell As New Shell32.Shell
Dim Temporary_Internet_Files As Shell32.Folder
Set Temporary_Internet_Files = mShell.NameSpace(32)
MsgBox Temporary_Internet_Files.Self.Path '這個就是路徑
Set Temporary_Internet_Files = Nothing
Set mShell = Nothing
End Sub
 

http://vbnet.mvps.org/index.html?code/internet/deleteurlcache.htm

通過API訪問IE Cache :

http://blog.csdn.net/technofantasy/archive/2002/03/29/2962.aspx


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章