2/07/2006

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:user@domain.microsoft.com "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



No comments: