为了便于搜索(http://search.csdn.net),这里尽可能保留了论坛上讨论的原文,但是这并不表示本人赞同帖子中的表述方式和观点。

CSDN 讨论总结系列:

  • Jiangsheng的CSDN Digest(April 3, 2006) (http://blog.csdn.net/jiangsheng/archive/2006/04/03/648980.aspx)
  • Jiangsheng的CSDN Digest(March 4, 2006) (http://blog.csdn.net/jiangsheng/archive/2006/03/05/615714.aspx)
  • Jiangsheng的CSDN Digest (Jan 21 2006)( http://blog.csdn.net/jiangsheng/archive/2006/03/05/615669.aspx)
  • Jiangsheng的CSDN Digest (Jan 7 2006)(http://blog.csdn.net/jiangsheng/archive/2006/01/07/573288.aspx)
  • Jiangsheng的CSDN Digest (Jan 1 2006)http://blog.csdn.net/jiangsheng/archive/2006/01/01/568362.aspx
  • Jiangsheng的CSDN Digest (Dec 2005)(http://blog.csdn.net/jiangsheng/archive/2005/12/24/561501.aspx)
  • Jiangsheng的CSDN Digest (Oct 2005)(http://blog.csdn.net/jiangsheng/archive/2005/12/27/563274.aspx)
  • Win32 & .Net Q&A 200509 (http://blog.csdn.net/jiangsheng/archive/2005/09/13/480540.aspx)
  • Win32 & .Net Q&A (http://blog.csdn.net/jiangsheng/archive/2005/02/28/304654.aspx)
  • VC/MFC Q&A 200407 (http://blog.csdn.net/jiangsheng/archive/2004/07/13/40771.aspx)

内码转换(Shift-JIS -> GBK)中遇到的问题(VB 基础类)


Function SJisToGBK()Function SJisToGBK(sSJis As String) As String Dim iLen As Integer Dim sUnicode As String Dim sGbt As String Dim sGbs As String iLen = LenB(sSJis) sUnicode = Space(iLen + 1) MultiByteToWideChar 932, 0, sSJis, -1, sUnicode, iLen iLen = LenB(sUnicode) sGbt = Space(iLen + 1) sGbs = Space(iLen + 1) WideCharToMultiByte 936, 0, sUnicode, -1, sGbt, iLen, vbNullString, 0 iLen = LenB(sGbt) LCMapString &H804, &H2000000, sGbt, iLen, sGbs, iLen SJisToGBK = sGbs End Function

是由网上搜来的一个 BIG5 -> GBK 的函数改的, 不过其中一些参数没弄得很明白, 只好照抄. 试了一下, 发现一些问题, 一是片假名无法转换, 二是部分汉字的转换会出现异常, 返回值里有一大堆问号.


DECLARE Function ConvertINetString()FUNCTION ConvertINetString _ LIB "MLANG.DLL" _ ALIAS "ConvertINetString" ( _ BYREF lpdwMode AS DWORD, _ BYVAL dwSrcEncoding AS DWORD, _ BYVAL dwDstEncoding AS DWORD, _ BYREF lpSrcStr AS ANY, _ BYREF lpnSrcSize AS LONG, _ BYREF lpDstStr AS ANY, _ BYREF lpnDstSize AS LONG _ ) AS LONG

也可以尝试使用ConvertINetUnicodeToMultiByte、ConvertINetMultiByteToUnicode。


如何用VBA将一个word中某一特定样式的文本替换为空(其他开发语言 Office开发/ VBA)


Selection.Find.ClearFormatting Selection.Find.Style = ActiveDocument.Styles("Heading 1") Selection.Find.Replacement.ClearFormatting Selection.Find.Replacement.Style = ActiveDocument.Styles("palawheading") With Selection.Find .Text = "^?" .Replacement.Text = "" .Forward = True .Wrap = wdFindContinue .Format = True .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute Replace:=wdReplaceAll

线程中动态更改页面(html)元素(VC/MFC ATL/ActiveX/COM)


编译环境 VS.NET 2003。使用 MSDN 的例子 mfcie 测试。 当页面下载完毕后,开启一线程,在线程中获得页面上的 IMG 元素,想动态更改其 src ,使用 put_src 就会出错 mfcie.exe 中的 0x7ccf9edf 处最可能的异常: 0xC0000005: 读取位置 0x00000034 时发生访问冲突。 但 put_height 、put_alt 等都没有问题,究竟是怎么回事呢?


it should be safe if IHTMLDocument2 interface is marshaled correctly. i.e. by CoMarshalInterThreadInterfaceInStream/CoGetInterfaceAndReleaseStream or via the IGlobalInterfaceTable interface.

see also http://vcfaq.mvps.org/com/1.htm


查询IHTMLDocument2接口失败(VC/MFC ATL/ActiveX/COM)


CComQIPtr<IWebBrowser2,&IID_IWebBrowser2> m_spWebBrowser2; <IDispatch> pDisp; HRESULT hr = m_spWebBrowser2->get_Document(&pDisp);
......
CComPtr
CComQIPtr<IHTMLDocument2,&IID_IHTMLDocument2>spHTML;
spHTML=pDisp;
if(spHTML)...{ …… }

spHTML总是为空,是什么问题呢?


需要处理DocumentComplete事件,参考http://www.codeproject.com/shell/AutomateShellWindow.asp


App.Path 函数不识映射驱动器,怎么办(VB 基础类)


我把服务器(机器名为htc-4100)上的某个文件夹 z 映射为本机的Z盘,我有一个VB程序,里面有 App.Path 语句。我把这个VB程序放在服务器上而不是我的本机上。当我在本机上执行这个服务器上的程序时,App.Path 返回的结果是一个绝对路径如下://htc-4100/z/serverInfo 。现在我想让它返回我映射的Z盘,即Z:/serverInfo,而不是//htc-4100/z/serverInfo,程序该如何写?


Public Function GetAppDir() As String 'converts UNC of mapped drive to Logical Drive:/Path Dim fso As New FileSystemObject Dim dc As Variant Dim d As Variant Dim S As String Dim strPathName As String On Error GoTo DriveErr strPathName = App.Path Set dc = fso.Drives For Each d In dc S = d.ShareName If InStr(1, S, fso.GetDriveName(strPathName), vbTextCompare) Then GetAppDir = Replace(strPathName, fso.GetDriveName(strPathName), d.DriveLetter & ":", 1, 1, 1) End If Next Set fso = Nothing Exit Function DriveErr: Resume Next End Function

文件路径和对话框的问题(C/C++ C++ 语言)


比如我的程序在d://programe,然后我调用GetCurrentDirectory(128,buf)函数获得的路径也确实是d:// programe。但是当我调用CFileDialog pMyOpenDlg(TRUE)用户通过打开文件对话框选择资源后,再调用GetCurrentDirectory函数得到的路径却是对话框所选择的对 话框(比如,用户使用对话框选择的路径是e://Mp3,则此时我程序中调用GetCurrentDirectory得到的路径是e://Mp3而不是我 程序的路径d://programe,这个问题该怎么解决啊?


不要依赖于GetCurrentDirectory返回的目录。获得当前模块所在目录可以用GetModuleFileName和PathRemoveFileSpec。


CStatic中怎样显示显示菜单的Prompt(VC/MFC 界面)


SDI中菜单的Prompt可以直接在CStatusBar中显示出来.现在想在Dialog窗体中的一个CStatic上显示菜单的Prompt,不知道怎么做.


Handle the WM_MENUSELECT message. The wParam is the menu index, which is also the index of the string table entry that describes the menu. This prompting is ordinarily handled by the mainframe, but in a dialog-based app you have to add your own handler

You can look at the code in the mfc/src/winfrm.cpp, although it is very general; you probably only need a subset of it.


一次性将页面中所有TextBox的值清成空,将DropDownList的默认选中值为第一行(.NET技术 ASP.NET)


想搞一个通用函数,能够将恢复页面的默认状态。


manually clearing all the entry fields controls may cause the page code become tight-coupled, but it'll be the most efficient way. Also, if you want to make it more flexible, you can use the FindControl method to find all the entry fields controls through the control ID and reset their text property, but this will be much less efficient.

foreach(Control control in Page.Controls[1].Controls) ...{ switch(control .GetType().ToString()) ...{ case "System.Web.UI.WebControls.TextBox": ((TextBox)control ).Text = ""; break; case "System.Web.UI.WebControls.DropDownList": DropDownList ddl = (DropDownList)control ; ddl.SelectedIndex = -1; break; } }

the best way to do this (assuming you can hard code your form) is to make the reset a standard HTML button:

<INPUT TYPE=BUTTON onClick="javascript:clearForm()" NAME="FormToClear">

and then code up some client side script to clear each of the form fields - Pseudo code:

function clearForm() { document.formname.FormToClear.value = "" ... etc }


DataGrid新增一行(.NET技术 ASP.NET)


private void bt_insert_Click(object sender, System.EventArgs e) ...{ string sql="select * from Code where Codeid='1'"; executesql.RunSqlDataSet(sql); DataTable tbcode=executesql.RunSqlDataSet(sql).Tables[0]; DataRow dr = tbcode.NewRow(); dr[0] = 1; dr[1] = ""; dr[2] = ""; dr[3] = true; tbcode.Rows.Add(dr); //再次绑定 DataGrid1.DataSource = tbcode; DataGrid1.DataBind(); } 上面的代码是在Datagrid外部点一下按钮datagrid新增了一行 但是如果再点一下按钮 让datagrid再新增加一行,怎么做 我现在发现就是你点10次,它也就新增加一行 难道再每次点新增都要先遍列一遍datagrid插入数据库,然后再新增吗? private void bt_insert_Click(object sender, System.EventArgs e)

private void bt_insert_Click(object sender, System.EventArgs e) ...{ string sql="select * from Code where Codeid='1'"; executesql.RunSqlDataSet(sql); DataTable tbcode=executesql.RunSqlDataSet(sql).Tables[0]; DataRow dr = tbcode.NewRow(); dr[0] = 1; dr[1] = ""; dr[2] = ""; dr[3] = true; tbcode.Rows.Add(dr); //再次绑定 DataGrid1.DataSource = tbcode; DataGrid1.DataBind(); //写入插入数据库的代码 }

} 有没有借助seesion的方法先把新增的存进去,最后点保存后直接全部更新数据库呢?怎么做啊 谢谢



可以参考 http://lucky.diy.myrice.com/javascriptexam/addelement.htm  一次存入数据库,或者用一个用session缓存中的DataSet来做数据源

参考http://dotnet.chinaitlab.com/ASPNET/363515.html 和http://msdn.microsoft.com/msdnmag/issues/03/07/DataPoints/


使用ActiveX控件时,怎么设定它的图像列表ImageList(VC/MFC ATL/ActiveX/COM)


在MFC客户程序中加了一个ActiveX控件, 这个控件有一个属性是设定它的ImageList的。 void CXYZ::SetImageList(LPUNKNOWN Value) { static BYTE parms[] = VTS_UNKNOWN; InvokeHelper(0x2c, DISPATCH_METHOD, VT_EMPTY, NULL, parms, Value); }

请问在我的程序中,该怎么传一个参数给它,试了CImageList类程序运行时会有错误。


Create a COM object using this CLSID

MSComctlLib.ImageListCtrl

This is Microsoft ImageList Control 6.0 (SP6).

http://msdn.microsoft.com/library/en-us/com/html/7295a55b-12c7-4ed0-a7a4-9ecee16afdec.asp


关于对话栏控件与视图的通信问题(VC/MFC 界面)


我建了一个SDI工程,静态分割成两个窗格,添加了对话栏。我在其中一个视图中打开一副图片,想在对话栏的ComboBox控件上显示其路径;或者我想点击对话栏的某个按钮,在一个视图中打开一副图片,应该怎么作?


DialogBar上的按钮可以当作工具栏按钮来映射命令消息。工具栏是框架的子窗口,可以通过框架来访问其中的控件

See the MFCIE sample(MFC) in MSDN toolbar和DialogBar都是ControlBar,控件消息都会往父窗口发的


问个关于网页和图片编程的问题(.NET技术 C#)


程序中有一个 axWebBrowser ,一个 PictureBox
现在我想实现的功能是:
用 axWebBrowser 浏览一个网页,然后找到网页里的验证码图片,把它显示在 PictureBox 里面
请问应该怎样做?
注意:由于要获取的图片是验证码,所以不能采用从网页中得到 src 然后通过 src 从网上重新下载这个最容易想到的方法

既然可以用 exeCommand 实现把图片复制剪贴板,
能不能用 exeCommand 实现把图片存在硬盘某文件夹下呢?


How To Programmatically Copy an IMG Element to the Clipboard
http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B293125

it is already in the cache, use FindFirstUrlCacheEntry/FindNextUrlCacheEntry to look for it


UI Thread为什么必须先从CWinThread派生一个类(VC/MFC 基础类)


CWinThread本来就有一个消息循环,为什么还要从CWinThread派生一个类?难道是为了动态创建?在mfc中,一个worker thread是否也可以当作UI thread使用?
比如:
CWinThead* pThread=AfxBeginThread(ThreadFunc, ...)
...
这里就不能:pThead->Run();吗?也就是不能当作UI Thead使用吗?


派生是为了扩展自己的功能。如果不需要,那么也可以直接用CWinThread.你在线程外调用这个函数,那么代码就在当前调用线程中执行,而不是在创建的线程中执行。这样是跨线程访问MFC对象,比较危险。


installshield安装过程中调用dll的问题(Delphi 网络通信/分布式开发)


用installshield调用delphi编写的序列号验证的dll文件中的函数,出现如下错误:

Error Number: 0x80040707
Description: Dll Function Call Crashed
Setup will now terminate.

百度搜索的有位高人说,dll函数传递字符串参数不能超过两个吗?


不是参数数目的问题(http://www.codeproject.com/debug/debugis.asp),检查一下参数个数、类型和函数调用约定。参考

HOWTO: Making a Custom Delphi DLL Work as an Extension
http://support.installshield.com/kb/view.asp?articleid=Q100899


ole的自刷新(VC/MFC ATL/ActiveX/COM)


在容器中的ole对象,如何实现自刷新?ole对象如何得到自己在容器中的位置?


InvalidateControl

CComControl::FireViewChange or COleControl::Refresh()

OR

Invalidate the container window
http://support.microsoft.com/support/kb/articles/q150/2/04.asp


IWebBrowser2 的指针,能指向一个iframe么(VC/MFC 网络编程)


想要在iframe中读写元素 跟在网页中读取一摸一样,以便实现代码的较高可重用性。


不是很一样。虽然框架对象支持IWebBrowser2接口,但是并无Windows窗口对象与之对应。
参见blog.csdn.net/jiangsheng/archive/2003/11/09/3795.aspx中的源代码


WindowsXP SP2中使用rawsocket进行TCP传输(C++ Builder 网络及通讯开发)


send error!:10049
有人说:
为了预防 DDOS增加安全性MS做了修改
Raw Socket 在XP中已经不能实现发送TCP包了 UDP尚可 混合模式监听功能尚可
不知道是不是真的
那就没有办法用rawsocket进行TCP传输了???
那么的话就没有办法伪装IP了~~~???


no in user mode. in kernel mode, you can write a device driver that plugs into the NDIS stack and communicates directly with the network card device driver.


请教关于OpenGL屏幕模式的几个问题(VC/MFC 基础类)


对OpenGL不是很熟,不过迫切的想了解下面的几个关于OpenGL屏幕的问题,希望得到大家的帮助,谢谢!

OpenGL支持全屏幕“独占”模式吗?还是仅仅只支持将窗口客户区调整得跟屏幕一样的尺寸,而不是真正的独享屏幕显示资源?
OpenGL全屏模式下的双缓冲或多缓冲机制支持像DirectX全屏模式那样的真正的Flip机制吗?

以上问题仅限于讨论OpenGL的Windows版本。

OpenGL本身不支持所谓的全屏模式。相对而言,DirectX 是真正支持独占显示模式的,并且能决定有与之联系紧密的一些绘图特性,如Flip机制就能在显卡级别交换硬件的显示缓冲的地址,而OpenGL不可能做到。我的理解正确吗?

我的目的是想弄清楚OpenGL在利用硬件的能力上(OpenGL是支持硬件加速的吧)与Direct3D有哪些差别。

对于 Direct3D,按照你的说法,Direct3D也只是一个3D的API函数,它也没有界面和窗口,但是D3D有一个函数支持直接设置全屏独占模式: CreateDevice()参数中的pPresentationParameters->Windowed为FALSE的话,D3D就工作在全屏 独占模式,在这种模式下如果pPresentationParameters->SwapEffect为D3DSWAPEFFECT_FLIP的 话,在Present()的时候,就是交换硬件显示缓冲地址的。

对于OpenGL,也不尽然如你所说的,网上查到有个这样的函数:glutFullScreen()可以设置全屏方式,不过其具体的实现,仍然就是像你说的那样,是通过Windows里面的设置。

最后,回到我的疑问上来,不论OpenGL本身支持不支持,到底有没有可能通过某种非D3D的手段(通过其它第三方库等等),使OpenGL工作在类似于D3D的真正全屏模式下,并且SwapBuffers()函数交换的是硬件的显示缓冲地址?

基于我的一个初步的研究结果,对于swapbuffer这样的操作,基于OpenGL的程序,即使是在全屏模式下,没有任何一例是“通过寄存器来切 换地址”的,统统都是copy的方式,例如CS之类的游戏。而基于D3D的全屏方式的游戏,大部分都是真正的“通过寄存器来切换地址”,我曾想办法在 D3D全屏方式下正常显示窗口,结果失败了,窗口都是闪烁的,由此可见的确是“通过寄存器来切换地址”。这才引发了我对OpenGL的“全屏模式”是否能 “通过寄存器来切换地址”的疑问,因为若基于OpenGL的程序没有这个能力,我就可以确保正常显示出窗口而不用担心窗口会闪烁,然后我会集中精力想办法 去解决 D3D下如何不闪烁的问题。

讨论了半天,我还是没有得到一个确切的答案。我再把问题有针对性地描述一下:

OpenGL的swampbuffer在什么情况下是“通过寄存器来切换地址”的?如何能证明这一点?

本贴不是要讨论OGL和D3D孰优孰劣,仅仅只是希望能够确认一下我的研究结论而已。而且这个研究结论对于我手上的工作很重要。
我的研究结论是:

1)窗口模式下:
a. OpenGL的SwapBuffers()函数交换的是内部缓存的地址,前台缓存是copy到屏幕上的。
b. Direct3D的Present()函数也是交换的内部缓存的地址,前台缓存也是copy到屏幕上的。

结论:窗口模式下,因为需要与其它应用程序并存,所以不论是OpenGL还是D3D的底层实现都不允许硬件的显示缓存地址。

2)全屏模式下:
a. OpenGL的SwapBuffers()函数交换的仍然是内部缓存的地址,前台缓存仍然是copy到屏幕上的。工作方式与窗口方式无异,可以理解为假全屏,或者说OpenGL本身就无真全屏的概念。
b. Direct3D的Present()函数此时可能存在两种行为:一种仍然是交换内部缓存的地址,前台缓存仍然是copy到屏幕上的;另一种就是直接通知硬件交换显示缓存的地址。

结论:对于一个3D引擎来说,本来是不应该去牵扯窗口模式或全屏模式之类的问题,OpenGL可能就是这样想的,所以对于OpenGL来说,窗口和全屏没 有区别;但微软就不同,从DirectX诞生之日开始,对于窗口模式和全屏模式就有一定的区别对待,DirectX一直支持一种叫Flip的机制,在全屏 独占模式下就提供页翻转的能力(当然你也可以不用页翻转)页翻转会导致整个屏幕当前显示的内容所映射的显存物理地址会发生改变。对于现在的硬件性能来说, 的确也翻转也没有了太大的速度上的优势,copy已经足够快了,但是页翻转仍然是被DirectX所支持的。

最后,引用一段MSDN里的内容回应一下madmanahong(疯子阿虹)吧:
这是 D3DPRESENT_PARAMETERS 参数说明中的一小段文字:
SwapEffect - Member of the D3DSWAPEFFECT enumerated type. The run time will guarantee the implied semantics concerning buffer swap behavior. So if Windowed is TRUE and SwapEffect is set to D3DSWAPEFFECT_FLIP, then the run time will create one extra back buffer, and copy whichever becomes the front buffer at presentation time.

大意就是说,若Windowed为TRUE(也就是窗口模式下)同时SwapEffect指定为D3DSWAPEFFECT_FLIP,那么在运行时会自 动创建一个额外的后备缓冲(此时就至少会有2个后备缓冲了),每次Present的时候,就那个将要成为前台缓冲的内容copy到这个后台缓冲区中,然后 与下一个后备缓冲交换指针,从而完成假页翻转。
言外之意就是,若Windowed为FALSE(也就是全屏模式下)同时SwapEffect指定为D3DSWAPEFFECT_FLIP,就不会创建额外的后备缓冲,每次都会是真正的页翻转。

写过基于DirectDraw或Direct3D的中文网络游戏的人可能都遇到过这样的问题:
如果希望能在游戏中正常使用系统的各种输入法的话,那么在2D全屏游戏中不能用Flip()函数来交换前台和后备缓中,而只能用Blt()函数来copy它们;在3D全屏游戏中不能指定 D3DSWAPEFFECT_FLIP页翻转标志,而只能指定D3DSWAPEFFECT_COPY标志。否则输入法的窗口将会不断地闪烁,因为输入法的窗口并不能适应也翻转,它只能画在其中一页上。

对于OpenGL,似乎就没有以上这些设置,不过还好,它不会页翻转,所以窗口也不会闪烁。
我所担心的就是,OpenGL会不会什么时候也开始页翻转了,窗口就会闪烁了?


"Fulll-screen" isn't a mode, and there isn't an API to enter it -- full screen is just a consequence of other normal actions. What applications normally do is to create a WS_POPUP and WS_EX_TOPMOST window whose dimensions are GetSystemMetrics(SM_CXSCREEN), ...CYSCREEN. This obscures the rest of the screen and so looks full.

If an app has changed resolution first, using ChangeDisplaySettings(CDS_FULLSCREEN), then I don't know what GetSystemMetrics(...) returns. Note that, despite the name of this API call, I think it'd be wrong to call it a "mode". The function still allows other windows to be shown on the desktop normally, albeit at a different resolution. ChangeDisplaySettings is often used in OpenGL games.

Still, if you tried to grab exclusive mode for yourself and were denied, that'd be a good sign that someone else had it.

see also
Adding a Full Screen Feature to an MFC Application
http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B164162

全屏幕确实是windows系统的问题,没有真正的全屏幕和非全屏幕的区别的

根据显示卡的工作原理, 一个屏幕上的内容占据的显存空间只是显卡的一个部分
具体的是哪个部分,是由硬件的寄存器来控制的
所谓的swapbuffer这样的操作,也只是通过寄存器来切换地址而已
显卡本身根据寄存器上的地址,状态,以及端口信息来解释该地址下面的内容如何显示
也正是因为这样,这个操作的速度才非常的快,可以在显示卡显示原有内容的同时,你处理后台buffer的内容,完成后再swap他们

显卡工作原理本身,不分全屏不全屏的,在它的眼中永远是全屏的;
分的是文本方式还是图形方式;用的是显存还是内存还是agp内存

dx 早期是不支持windows模式下的flip的,只支持全屏幕独占方式下的flip
windows下的不支持flip的原因很简单,因为大家都共享这个桌面,不能简单的替换

swapeffect是dx9后的概念,它在windows下的flip允许也是特殊实现的
如同前面说的,flip实际上是发生在backbuffer和一个中间内部buffer,然后从中间的内部buffercopy到桌面区域,这个copy也是显卡内部数据的copy,速度也是很快的

从pc显示卡工作的原理上来说,opengl支持这个层面是没有问题,但是opengl是一个跨平台的系统; 而directx是必须依赖于windows平台的,在单一平台下,微软可以控制一切
这种显卡内存显示地址flip属性在其他的计算机系统和操作系统上能否支持,是个疑问;

如果opengl没有提供这样的功能,个人认为也是考虑跨平台跨系统兼容效果的原因

至于opengl是否会突然改变策略,这个不值得担心!


如何取machine.config或者web.config中的<system.web>中设置的值(.NET技术 ASP.NET)


如:

<system.web> <httpRuntime executionTimeout="120" maxRequestLength="10240" useFullyQualifiedRedirectUrl="false" minFreeThreads="8" minLocalRequestFreeThreads="4" appRequestQueueLimit="100" enableVersionHeader="true"/> </system.web>

要取得maxRequestLength的值为10240


string filename = "c://inetpub//wwwroot//netcardsweb//Web.config"; XmlTextReader xmlReader = new XmlTextReader(filename); XmlDocument xDoc = new XmlDocument(); xDoc.Load(xmlReader); xmlReader.Close(); System.Xml.XmlNodeList nodelist = xDoc.GetElementsByTagName("appSettings"); nodelist.Item(0).ChildNodes.Item(0).Attributes.Item(0).Value = "DataBaseName"; nodelist.Item(0).ChildNodes.Item(0).Attributes.Item(1).Value = "MyNewDb"; xDoc.Save(filename);

请问如何提高VBA宏的执行效率(其他开发语言 Office开发/ VBA)


我有一个文档,里面有不同的格式,比如:标题1,标题2,标题3什么的。
我的目的是要把这些标题1/标题2/标题3的格式段的文本内容导入到 Excel表格中,但是由于word文档本身比较大,里面大概有2万多个paragraph,大概有400多页,导入的速度非常慢,导致我运行了很久都没有运行完,最后就死了,请问各位高手,有没有什么优化的手段,我的宏的思路是:

set ExcelWS = createobject("excel.sheet") for i = 1 to activedocument.paragraphs.count if activedocument.paragraphs(i).style = "标题 1" then excelws.application.cell(iCell,1).value = activedocument.paragraphs(i).range.text end if if activedocument.paragraphs(i).style = "标题 2" then excelws.application.cell(iCell,1).value = activedocument.paragraphs(i).range.text end if if activedocument.paragraphs(i).style = "标题 3" then excelws.application.cell(iCell,1).value = activedocument.paragraphs(i).range.text end if next i ExcelWS.saveas "try.xls"

我的问题是:
1 上面的算法是不是有问题,导致最后运行很慢;
2 在运行过程中,我怀疑是excel存盘,我没有处理好,导致程序一直需要缓存要存盘的东西,
由于对vba不熟悉,有没有好的存盘策略和方法,能让很快的执行完毕。


ou could speed up Word considerably by replacing the slow parts of your code with faster coding, but there's no way Word will ever be able to do anything with a 20MB text file with any perceptible speed.

the slow parts:

For i = 1 To ActiveDocument.Paragraphs.Count

[this is incredibly slow]

instead use

For Each aPara In ActiveDocument.Paragraphs

关于Image类中几个方法的问题(专题开发/技术/项目 图形图像/机器视觉)


1 .NET中Image::Save的对象的存储问题
当Image的一个对象用同一个文件名进行save时不会成功。你们是怎么处理图像保存的?

2 Image::GetItemData的问题

MSDN中能够查得到Image::GetItemData,但对于Image的对象却无法找到GetItemData这个方法,为什么?

3 ImageItemData类的问题:
MSDN中的说明如下
Class Information

Header Declared in Gdiplusimaging.h, include gdiplus.h
Import library gdiplus.lib
Minimum availability GDI+ 1.1
Minimum operating systems Windows 98, Windows XP, Windows 2000, Windows NT 4.0 SP6

建立了一个ImageItemData的对象,却说ImageItemData没有定义,在
Gdiplusimaging.h中也没有找到该定义,为什么?

1。把文件的副本放到了另外一个文件夹里面,在文档类中打开、操作该副本。但是想在程序结束时删除这些副本,不知道这些删除代码放在哪里?
我在应用程序类里面试了几个地方(CMDIRSApp::ExitInstance()和CMDIRSApp::~CMDIRSApp())都不行。也应 用了CloseAllDocuments(true);在点菜单退出系统按钮时,只要是当前打开的图像没有关闭,就删除不了,若是当前没有打开图像就可以 删除。怎么解决?

2。我用的是vs.net2005,仍然不能得到GDI+1.1的版本?

关于Image::FromStream(IStream *stream, BOOL useEmbeddedColorManagement);
其中的参数stream应该是一个图像文件的什么内容的数据流?


1 check Image::GetLastStatus
2 you can always use GDI+ directly
3 check the namespace. the default namespace is Gdiplus, which means the gdi+ classes are not global.

1 All GDI+ references to the original file must be closed (objects destroyed)
before an Image.Save() will work against that filename.

Maybe you can GetTempFileName() and CopyFile() to a new file, open that
one, modify/save to original file name, delete temp file.

2 download a new platform sdk

1 handle CDocument::OnCloseDocument
2 then you should be able to access it. look into the mfc header file.

GDI+ 1.1 尚未发布。你所看到的是测试版本的文档。

Image::FromStream应该是图像文件格式,也就是说,如果stream参数指向一个CreateStreamFromHGlobal函数创建的内存流,那么和这个内存句柄关联的内存中的数据应该是和一个图像文件一模一样。


ASP.NET开发出来的网页,别人访问时,问什么如此之慢?(.NET技术 ASP.NET)


你变成release试试,把<compilation defaultLanguage="c#" debug="true" />debug改为False

网站编译后第一次访问就是很慢的。以后访问过的网页就快了

handle all events and write debug trace with timestamp
see

Understanding the ASP.NET Lifecycle (Redux)

Logging and Troubleshooting

http://www.aspnetpro.com/features/2006/05/asp200605au_f/asp200605au_f.asp


请教一个问题,关于整个执行程序转入虚拟内存的问题!(VC/MFC 基础类)


最近看到一款软件《雪狐桌面精灵》,这个软件有一个功能,是把自己执行程序的内存全部转移到虚拟内存中去,请问在MFC下如何才能做到这一点,一般 来讲用 API  VirtualAlloc可以对虚拟内存进行申请分配,但是这样只能达到程序自己需要用的数据分配到虚拟内存里,但是光是一个MFC向导生成出来的对话 框程序,使用Release发布,执行起来都需要占用至少3MB左右的内存,而前面提到的那个软件,可以让内存占用保持在680KB左右,这是如何做到 的?


实际上MFC的代码大家都共享的,总共占用的内存并不是每个程序占用内存之和.VC++界面菜单--  >project--  >setting--  >link--  >stack  alloc里面可以设置总内存和物理内存.SetProcessWorkingSetSize(GetCurrentProcess(),-1,-1);


IE上调用AvctiveX,事件与方法响应顺序问题(VC/MFC ATL/ActiveX/COM)


我用VC7.0建立了一个ActiveX,我需要在一个网页上调用ActiveX某个接口方法之前执行Acitvex的OnCreate事件,但是 正好相反,每次都先执行ActiveX的那个接口方法,后执行OnCreate事件.以至于我无法取得这个Activex在此时的句柄!


See Q195188 ( http://support.microsoft.com/kb/195188) PRB: ActiveX Control Window Is Not Created Until Visible in Internet Explorer


请教dos下调用MFC程序如何实现dos下输出?(VC/MFC 基础类)


编写了一个mfc对话框程序,但是想在dos调用这个程序,同时希望把出错信息输出到dos下,请教怎么
在dos下输出出错信息?好像直接printf不行啊


MFC is not supported by DOS. If you are writing a console app, use WriteConsole.


请问 stdcall 和 _stdcall 和 __stdcall 有什么区别和关系(VC/MFC ATL/ActiveX/COM)


"__stdcall" is the Microsoft specific name of the "stdcall" calling convertion. Unlike __cdecl (the native calling convention of C/C++), it is supported in C/C++, Visual Basic, Java, and other languages alike, which makes it the first choice when building a DLL for cross-language use.

In Microsoft C++, identifiers with two leading underscores are reserved for compiler implementations. Therefore, the Microsoft convention is to precede Microsoft-specific keywords with double underscores.


VC下如何使用TStringGrid或者MSFlexGrid(VC/MFC Visual C++ 资源)


TStringGrid是Borland的,VC里面没有
MSFlexGrid是Visual Studio附带的ActiveX,装了Visual Studio就有
使用方法参见
http://support.microsoft.com/default.aspx?scid=kb;en-us;196833


有没有方法改变树型控件被选中时的背景色(VC/MFC 界面)


http://www.developer.com/net/cplus/article.php/637411


在DLL里面初始化一个Automation对象,如果我写在InitInstance()写会进入死循环?(VC/MFC 进程/线程/DLL)


在DLL里面我这么写的:

BOOL CDNCMaxOEMLinkApp::InitInstance() ...{ CWinApp::InitInstance(); // 将所有 OLE 服务器(工厂)注册为运行。这将使 // OLE 库得以从其他应用程序创建对象。 COleObjectFactory::RegisterAll(); if(!m_App.CreateDispatch("XTFrameWorkPro.IApplication")) ...{ AfxMessageBox("创建XTFrameWork服务失败!"); } return TRUE; }

在这一句系统就死循环了m_App.CreateDispatch("


export a function and create the object in the function,InitInstance封装的入口函数DLLMain里面不能加载其它DLL(比如创建COM组件),不然会造成死锁,这个是Windows的限制


用VS2005如何生成本地代码(VC/MFC 基础类)


我在VS2005中建立了一个WIN32 CONSOLE项目,在项目设置中明确的关闭了CLR,但这时生成的应用程序在没有安装。NET 2.0的机器上无法运行。请问如何生成本地代码?


No you do not need the .NET FX 2.0 to run the win32 console app, if you are not using any managed C++/CLI stuff.

What you do need is probably the CRT (msvcr80.dll and msvcp80.dll) if you are using dynamic CRT DLLs instead of static in your project settings.

If you change to static libraries in your project settings then you do not need those either.

To change to use the static libraries, just go under:

Project - Properties - Configuration Properties - C/C++ - Code Generation

and for release settings change from:

Multi-threaded DLL (/MD)

to:

Multi-threaded (/MT)

and for debug settings change from:

Multi-threaded Debug DLL (/MDd)

to:

Multi-threaded Debug (/MTd)

reference
http://www.codeproject.com/cpp/vcredists_x86.asp

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=157129&SiteID=1


twebbrowser问题(Delphi VCL组件开发及应用)


当一个activex需要被安装的时候,屏蔽原来弹出提示窗口,如何在自己的dialog中显示他们的信息GUID,名称等?


这需要实现一个自定义的安全管理器
参照http://msdn.microsoft.com/workshop/security/szone/overview/impl_secmanager.asp


能否用masm配Turbo Debugger进行源级调试(其他开发语言 汇编语言)


我们知道tasm、tlink配合Turbo Debugger可进行源级调试。

不知道masm、link配合Turbo Debugger是否也能这样,自己试了半天,没成功。


我一般用windbg或者Visual C++来进行调试
http://support.microsoft.com/support/kb/articles/Q106/3/99.asp


请问.net中有没有api钩子的类(.NET技术 VC.NET)


Except for the WH_KEYBOARD_LL low-level hook and the WH_MOUSE_LL low-level hook, you cannot implement global hooks in the Microsoft .NET Framework. To install a global hook, a hook must have a native DLL export to inject itself in another process that requires a valid, consistent function to call into. This behavior requires a DLL export. The .NET Framework does not support DLL exports. Managed code has no concept of a consistent value for a function pointer because these function pointers are proxies that are built dynamically.
http://support.microsoft.com/default.aspx?scid=kb;en-us;318804

Strictly speaking, it may not be appropriate to call the WH_KEYBOARD_LL low-level hook and the WH_MOUSE_LL low-level hook "global hooks". The callback functions are executed with the context of the original thread that installs the hooks, instead of the context of the target process.


如何制作可变大小的CDialogBar子类(VC/MFC 界面)


我从CDialogBar派生了一个子类
CContainerDlgBar
重载了其中的虚函数CalcDynamicLayout
然后调用CDialogBar::CalcDynamicLayout来获得原始窗口大小
判断窗口的停靠,我的代码如下:

CSize CContainerDlgBar::CalcDynamicLayout( int nLength, DWORD dwMode ) ...{ CSize sz=CDialogBar::CalcDynamicLayout(nLength,dwMode); if(LM_STRETCH&dwMode)return sz; if(dwMode&LM_HORZDOCK)sz.cx=0x7fff; if(dwMode&LM_VERTDOCK)sz.cy=0x7fff; return sz; }

但是这样写有个问题,就是每次我要挪动窗口的时候,本来不是有个黑框表示位置么?
现在变成了一直延伸到屏幕底下了,或则上靠的时候一直延伸到屏幕右边去了
我看了微软的文献Q143255
拷贝了里面的代码根本不能工作


It's not provided by the normal CDialogBar. You might be able to fight with the sources for CDialogBar and its docking stuff and get it to working.
Or use CSizingControlBar http://www.codeproject.com/docking/sizecbar.asp .
Or you can buy a industrial strength stuff from bcgsoft (which is based on CSizingControlBar) or Stingray.


请问怎样在CHtmlView 里设置代理服务器(VC/MFC HTML/XML)


INTERNET_PROXY_INFO ipi; ipi.dwAccessType = INTERNET_OPEN_TYPE_PROXY; ipi.lpszProxy = _T("hogehoge.proxy.com:8080"); ipi.lpszProxyBypass = NULL; HRESULT hr = ::UrlMkSetSessionOption(INTERNET_OPTION_PROXY, (void *)&ipi, sizeof(ipi), 0);

如何用installshield制作一个驱动程序的安装包(硬件/嵌入开发 驱动开发/核心开发)


我这sys,inf,vxd文件都有了,如何用installshield制作一个自己的安装包呢。
文件清单:
Setup.sit
Serwpl.inf
Uninstall.exe
ser2pl.sys
SER9PL.sys
Serspl.inf
Serspl.vxd
请大家帮帮忙。


http://www.installsite.org/pages/en/isp_ext.htm


开发Office2003插件的问题(VC/MFC ATL/ActiveX/COM)


现在网上很多开发office插件的资料都是关于office2000和xp的,但是我发现2003和前面2个都不兼容,office类型库名称不 一样(库里的内容就不知道是否一样了),怎样编写一个这样一个插件,让它对office三个版本都兼容?或者谁有关于office2003插件开发的资料


Office introduced new properties, methods, and objects in each upgrade. So, if you use any of those constructs, or use early binding, your code will not be backwards compatible.

If you don't, your code might work. In general, consider developing the software using the oldest version of the software on which you want it to work, and use late binding. Unless there are breaking changes in the Office application, that code will be forward compatible.

References

  • INFO: Writing Automation Clients for Multiple Office Versions
    http://support.microsoft.com/kb/244167/
  • Office Automation Using Visual C++
    http://support.microsoft.com/kb/196776
  • INFO: Use DISPID Binding to Automate Office Applications Whenever Possible
    http://support.microsoft.com/kb/247579/
  • INFO: Using Early Binding and Late Binding in Automation
    http://support.microsoft.com/kb/245115/

关于ACTIVEX控件注册的问题(VC/MFC ATL/ActiveX/COM)


我用VC6做了一个ACTIVEX控件MAPCTRL.OCX,它调用了一个图形动态库GIDS.DLL,该DLL是由VC.NET生成的,编译 MAPCTRL.OCX时执行到REGISTER ACTIVEX CONTROL....就死掉了,很明显是注册时出了问题,好象在找什么文件,可是我已经把GIDS.DLL和.NET的四个DLL和用到的 GDIPLUS.DLL放到该目录下了,实在想不出是什么问题,求各位大侠指导.(另:我以前用VC6生成的GIDS.DLL,注册时没有任何问题).


Try to initialize and uninitialize GDIplus DLLs after InitInstance and before ExitInstance, such as the constructor and destructor of your ActiveX control class.

Quote
------------------
The entry-point function should perform only simple initialization or termination tasks. It must not call the LoadLibrary or LoadLibraryEx function (or a function that calls these functions), because this may create dependency loops in the DLL load order. This can result in a DLL being used before the system has executed its initialization code. Similarly, the entry-point function must not call the FreeLibrary function (or a function that calls FreeLibrary) during process termination, because this can result in a DLL being used after the system has executed its termination code.
--------------
From http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/dllmain.asp


axwebbrowser编辑模式下按F5的问题(.NET技术 C#)


我用axwebbrowser。并且设置body的contenteditable=true.也就是可以编辑了。但是在编辑的过程中如果按下F5键就退出编辑模式,一片空白了。
或是,contenteditable=false,然后我设置innerhtml=...,但是当点右键,选择“刷新”后。也是一篇空白。
该怎样阻止刷新的操作呢?右键还好说一点,我可以换个右键。但是F5就不行了,我处理它的keydown事件好像也无济于事啊。


http://www.codeproject.com/internet/detecting_the_ie_refresh.asp

However, it is a doc error that each DWebBrowserEvents2::DownloadBegin event will
have a corresponding DWebBrowserEvents2::DownloadComplete event. The behavior is actually that when you get a DWebBrowserEvents2::DownloadComplete event, it applies to all of the DWebBrowserEvents2::DownloadBegin events you got since the last DWebBrowserEvents2::DownloadComplete. The intent of these two events is for "something is happening" UI to be started and stopped - they're not good for much else.

public class MyMainForm : System.Windows.Forms.Form, IMessageFilter ...{ const int WM_KEYDOWN = 0x100; public bool PreFilterMessage(ref Message m) ...{ Keys keyCode = (Keys)(int)m.WParam & Keys.KeyCode; if(m.Msg == WM_KEYDOWN && keyCode == Keys.F5) ...{ return true; } return false; } .... .... .... private void MyMainForm_Load(object sender, System.EventArgs e) ...{ Application.AddMessageFilter(this); } }

动态分配Dll中导出的C++类(VC/MFC 进程/线程/DLL)


现在从dll中导出一个类,使用的时候用new动态分配一个类的对象,为什么在调试版下用delete删除的时候会引发异常?


BUG: Wrong Operator Delete Called for Exported Class
http://support.microsoft.com/default.aspx?scid=kb;en-us;122675


问msxml如和控制缩进和换行(VC/MFC HTML/XML)


save后,节点的缩进全乱了,而且都挤在一行,有什么办法可以控制


appending "/n" or "/t" textnodes

var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.4.0"); xmlDoc.async = false; // preserveWhiteSpace is useful when loading // existing documents. xmlDoc.preserveWhiteSpace = true; xmlDoc.appendChild(xmlDoc.createElement("root")); xmlDoc.documentElement.appendChild( xmlDoc.createTextNode("/r/n/t")); xmlDoc.documentElement.appendChild( xmlDoc.createElement("child")); xmlDoc.documentElement.appendChild( xmlDoc.createTextNode("/r/n")); xmlDoc.save("test.xml");

you can also use MXXMLWriter and set its indent property
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/html/6139a6fe-7d4c-449d-9e36-60b68be1de71.asp

下面这个函数可以缩进:

void AddWhiteSpaceToNode(IXMLDOMDocument* pDom,IXMLDOMElementPtr xmlNode,BSTR bstrWs) ...{ IXMLDOMText *pws=NULL; IXMLDOMNode *pBuf=NULL; pDom- >raw_createTextNode(bstrWs,&pws); xmlNode- >raw_appendChild(pws,&pBuf); if (pws) pws- >Release(); pws=NULL; if (pBuf) pBuf- >Release(); pBuf=NULL; }

怎样在Dialog Based工程里添加Frame窗口(VC/MFC 界面)


我想写一个工程,要用基于对话框的界面,但是他的一些功能要用到基于框架的技术,我想在Dialog里通过点一个按钮,就打开一个Frame窗口,这个窗口可以最大最小化,并且它是Dialog的一部分或一个属性,可以调用Dialog中的其他函数或属性


http://www.codeproject.com/dialog/modalframe.asp


用空格键或 Enter键以激活此控件(VC/MFC 基础类)


WIN2003打了912812补丁后,在网页中自己的OCX控制就会出现一个虚框和一个提示(用空格键或 Enter键以激活此控件),到底是什么原因呀?可不可以在IE中设置后不会出现此现象?


http://msdn.microsoft.com/workshop/author/dhtml/overview/activating_activex.asp


请教 两个WebBrowser怎么共享Cookies?如果修改程序的User-Agent(Delphi 网络通信/分布式开发)


1 请教,如何是程序运行时,两个WebBrowser共享同一个Cookie.[?]
2 如何在不修改注册表的情况下修改用户提交的User-Agent?
3 WebBrowser中如何控制弹出窗口标题?


1 默认就是
2 http://www.euromind.com/iedelphi/embeddedwb/useragent.htm
3 实现IDocHostShowUI::ShowMessage
http://www.euromind.com/iedelphi/embeddedwb/tips.htm


浏览器看另一客户端传送的视频(.NET技术 ASP.NET)


A客户端登陆网站,网站获取A客户信息(包括动态IP),
B客户端也登陆网站,获取A的信息,然后通过IE看A传来的
视频信息。

为了减少网站负担,此视频信息不能通过网站中转,B客户端
登录后,就直接以P2P与A直接通信。

问题是A客户端有客户端软件,而B只能通过IE来看(Active插件?FLASH?),
该怎么做?安全性怎么样?


用Windows Media Service+Windows Media Player
安全性可以用DRM证书来做

http://www.microsoft.com/windows/windowsmedia/forpros/content_provider/broadcast/default.aspx


如何编写DataGrid自定义控件,扩展如下功能(.NET技术 C#)


当把它拖入设计器的时候点击“详细设计”就可以显示一个设计窗口,在设计这个控件的时候怎么写才能让ide知道这个选项、以及知道如何实例化这个设计窗口。另外这个窗口定义了属性之后、怎么通知设计器刷新程序源代码。


需要撰写控件的设计时支持代码,参见

  • http://www.yesky.com/377/1750877.shtml
  • http://www.codeproject.com/csharp/propertyeditor.asp
  • http://www.codeproject.com/csharp/customdesigner.asp

删除NTFS格式下目录继承的权限(VC/MFC 基础类)


BOOL bRetval = FALSE; HANDLE hToken = NULL; PSID pSIDAdmin = NULL; PSID pSIDEveryone = NULL; PACL pACL = NULL; SID_IDENTIFIER_AUTHORITY SIDAuthWorld = SECURITY_WORLD_SID_AUTHORITY; SID_IDENTIFIER_AUTHORITY SIDAuthNT = SECURITY_NT_AUTHORITY; const int NUM_ACES = 1; EXPLICIT_ACCESS ea[NUM_ACES]; DWORD dwRes; // Specify the DACL to use. // Create a SID for the Everyone group. /**//* if (!AllocateAndInitializeSid(&SIDAuthWorld, 1, SECURITY_WORLD_RID, 0, 0, 0, 0, 0, 0, 0, &pSIDEveryone)) { printf("AllocateAndInitializeSid (Everyone) error %u/n", GetLastError()); goto Cleanup; }*/ pSIDEveryone = GetSid(L"EveryOne", 0); // Create a SID for the BUILTIN/Administrators group. /**//* if (!AllocateAndInitializeSid(&SIDAuthNT, 2, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &pSIDAdmin)) { printf("AllocateAndInitializeSid (Admin) error %u/n", GetLastError()); goto Cleanup; }*/ ZeroMemory(&ea, NUM_ACES * sizeof(EXPLICIT_ACCESS)); // Set read access for Everyone. ea[0].grfAccessPermissions = GENERIC_ALL; ea[0].grfAccessMode = REVOKE_ACCESS; ea[0].grfInheritance = INHERITED_ACE; ea[0].Trustee.TrusteeForm = TRUSTEE_IS_SID; ea[0].Trustee.TrusteeType = TRUSTEE_IS_INVALID; ea[0].Trustee.ptstrName = (LPTSTR) pSIDEveryone; if (ERROR_SUCCESS != SetEntriesInAcl(NUM_ACES, ea, NULL, &pACL)) ...{ printf("Failed SetEntriesInAcl/n"); goto Cleanup; } // Try to modify the object's DACL. dwRes = SetNamedSecurityInfo( lpszOwnFile, // name of the object SE_FILE_OBJECT, // type of object DACL_SECURITY_INFORMATION, // change only the object's DACL NULL, NULL, // do not change owner or group pACL, // DACL specified NULL); // do not change SACL if (ERROR_SUCCESS == dwRes) ...{ printf("Successfully changed DACL/n"); bRetval = TRUE; // No more processing needed. goto Cleanup; } if (dwRes != ERROR_ACCESS_DENIED) ...{ printf("First SetNamedSecurityInfo call failed: %u/n", dwRes); goto Cleanup; } // If the preceding call failed because access was denied, // enable the SE_TAKE_OWNERSHIP_NAME privilege, create a SID for // the Administrators group, take ownership of the object, and // disable the privilege. Then try again to set the object's DACL. // Open a handle to the access token for the calling process. if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hToken)) ...{ printf("OpenProcessToken failed: %u/n", GetLastError()); goto Cleanup; } // Enable the SE_TAKE_OWNERSHIP_NAME privilege. if (!SetPrivilege(hToken, SE_TAKE_OWNERSHIP_NAME, TRUE)) ...{ printf("You must be logged on as Administrator./n"); goto Cleanup; } // Set the owner in the object's security descriptor. dwRes = SetNamedSecurityInfo( lpszOwnFile, // name of the object SE_FILE_OBJECT, // type of object OWNER_SECURITY_INFORMATION, // change only the object's owner pSIDAdmin, // SID of Administrator group NULL, NULL, NULL); if (dwRes != ERROR_SUCCESS) ...{ printf("Could not set owner. Error: %u/n", dwRes); goto Cleanup; } // Disable the SE_TAKE_OWNERSHIP_NAME privilege. if (!SetPrivilege(hToken, SE_TAKE_OWNERSHIP_NAME, FALSE)) ...{ printf("Failed SetPrivilege call unexpectedly./n"); goto Cleanup; } // Try again to modify the object's DACL, now that we are the owner. dwRes = SetNamedSecurityInfo( lpszOwnFile, // name of the object SE_FILE_OBJECT, // type of object DACL_SECURITY_INFORMATION, // change only the object's DACL NULL, NULL, // do not change owner or group pACL, // DACL specified NULL); // do not change SACL if (dwRes == ERROR_SUCCESS) ...{ printf("Successfully changed DACL/n"); bRetval = TRUE; } else ...{ printf("Second SetNamedSecurityInfo call failed: %u/n", dwRes); } Cleanup: if (pSIDAdmin) FreeSid(pSIDAdmin); /**//* if (pSIDEveryone) FreeSid(pSIDEveryone);*/ if (pACL) LocalFree(pACL); if (hToken) CloseHandle(hToken);

上述方法只能删除自己添加的权限,不能删除从父目录继承过来的权限
该如何实现不从父目录继承权限呢????


CSid sidDenied; sidDenied.LoadAccount(L"ADMINISTRATORS"); CDacl dacl; CSecurityDesc desc; dacl.RemoveAces(sidDenied); desc.SetDacl(dacl); desc.SetControl(SE_OWNER_DEFAULTED| SE_GROUP_DEFAULTED| SE_DACL_DEFAULTED| SE_SACL_PRESENT| SE_SACL_DEFAULTED| SE_DACL_AUTO_INHERIT_REQ| SE_SACL_AUTO_INHERIT_REQ| SE_SELF_RELATIVE, SE_DACL_PROTECTED); SetFileSecurity(lpszOwnFile,DACL_SECURITY_INFORMATION|GROUP_SECURITY_INFORMATION,&desc);

f you do not want to inherit permissions from the parent
directory, you need to use the SE_DACL_PROTECTED flag.

if you want to save a lot of code, you can use SDDL (security
descriptor description language). The security descriptor creation
code can be replaced by a single call:

ConvertStringSecurityDescriptorToSecurityDescriptor(
L"O:COD:(A;;FA;;;WD)",
SDDL_REVISION_1,
&pSD,
&dwSize
);
SDDL is documented in MSDN.


DataGrid怎么实现DataList中的RepeatColumns的功能(.NET技术 ASP.NET)


想显示一组数据,为了美观,希望每2组数据能并排显示,用DataList中的RepeatColumns=2实现了,但它分页太麻烦!请问各位高手,怎么在DataGrid中也能实现啊,在MSDN中查,未果.


你可以自己来写一个DataSource代理,把DataSource填充到DataSet之后把数据根据条件分到两个DataSet里面去。
为了减少内存占用,你需要自己实现分页机制,在DataSource里面去掉索引列和排序列之外的其他列,在要显示某一项的时候再根据索引列的值去查数据库。
这种方法不适合百万以上数据量的大型数据库。


一个win32 console application 在dos 窗口运行中,把dos窗口关闭,可以得到什么消息?如何得到?(VC/MFC 基础类)


BOOL WINAPI ConsoleHandler(DWORD CEvent) ...{ char mesg[128]; switch(CEvent) ...{ case CTRL_C_EVENT: MessageBox(NULL, "CTRL+C received!","CEvent",MB_OK); break; case CTRL_BREAK_EVENT: MessageBox(NULL, "CTRL+BREAK received!","CEvent",MB_OK); break; case CTRL_CLOSE_EVENT: MessageBox(NULL, "Program being closed!","CEvent",MB_OK); break; case CTRL_LOGOFF_EVENT: MessageBox(NULL, "User is logging off!","CEvent",MB_OK); break; case CTRL_SHUTDOWN_EVENT: MessageBox(NULL, "User is logging off!","CEvent",MB_OK); break; } return TRUE; } if (SetConsoleCtrlHandler( (PHANDLER_ROUTINE)ConsoleHandler,TRUE)==FALSE) ...{ // unable to install handler... // display message to the user printf("Unable to install handler!/n"); return -1; }

怎么实时得知webbrowser2控件的大小.位置被网页代码改变了(VC/MFC ATL/ActiveX/COM)


void CMyHtmlView::BeforeNavigate2(LPDISPATCH pDisp, VARIANT* URL, VARIANT* Flags, VARIANT* TargetFrameName, VARIANT* PostData, VARIANT* Headers, BOOL* Cancel) ...{ if ( m_bResizeWindow ) ...{ IWebBrowser2* pWB = NULL; // QI the dispatch for WebBrowser control. HRESULT hr = pDisp->QueryInterface( IID_IWebBrowser2, (void**)&pWB ); if ( SUCCEEDED(hr) ) ...{ long x,y; // Get dimensions. pWB->get_Width( &x ); pWB->get_Height( &y ); // Resize frame. SetScrollSizes( MM_TEXT, CSize(x,y) ); ResizeParentToFit(); pWB->Release(); } m_bResizeWindow = false; } }

用javascript怎么实现把多个图片淡入淡出的效果啊(Java J2EE / EJB / JMS)


<script language="JavaScript"> var b = 1; var c = true; function fade(){ if(document.all); if(c == true) { b++; } if(b==100) { b--; c = false } if(b==10) { b++; c = true; } if(c == false) { b--; } child.filters.alpha.opacity=0 + b; setTimeout("fade()",100); } </script> <img src="img/1.jpg" name="child" border=0 alt="Image" style="filter:alpha(opacity=0)">

上面的代码可以实现一张图片的淡入淡出

如果是多张图片

如第一张淡出后接着显示第二张,第二淡出后再显示第三个,那上面的代码要怎么改啊


http://msdn.microsoft.com/workshop/samples/author/dhtml/DXTidemo/DXTidemo.htm


[Shell]如何获得某个打开的文件夹的路径(VC/MFC 基础类)

怎么在BHO中创建一个IE窗口出来?(VC/MFC ATL/ActiveX/COM)


比如打开我的电脑(目的是启动一个Shell窗口),然后进入某个分区,打开某个文件夹。这时候启动我的程序找到这个Shell窗口,然后获得这个Shell窗口当前打开的文件夹的路径。

当然我可以通过GetWindowText获得,但是“文件夹选项”里面可以把“在标题栏显示完整路径”或“在地址栏显示完整路径”去掉。。。

现在就是找不到一个确定的方法来获得Shell窗口当前打开文件夹的完整路径。


www.codeproject.com/shell/AutomateShellWindow.asp


控件保存为图片(VC/MFC ATL/ActiveX/COM)


用ATL做了一个ACTIVEX控件,想用报表保存下来。但用respose转到word里面,控件里面从外面获取的数据画出的图型却不见了。因此希望能先把控件转为图片,在网上找了半天全是MFC的东东,我的控件不支持MFC啊。


转成WMF之后嵌入到RTF里面
msword的格式没有公开

http://support.microsoft.com/default.aspx?scid=KB;en-us;301044
http://www.microsoft.com/downloads/details.aspx?FamilyID=ac57de32-17f0-4b46-9e4e-467ef9bc5540&displaylang=en


有没有搞skype api二次开发的(VC/MFC 网络编程)


skype有没有提供接口读写这个设置

工具-〉选项 -〉输入输出设备 -〉启用音频设备设置的自动调节功能


http://msdn.microsoft.com/coding4fun/


为何换一种字体对话框的大小会变?(VC/MFC 界面)


一个对话框资源,换不同的字体(字号相同,例如都是9号)对话框的大小不一样。
想知道的是:这种大小的变化有什么规律?从某字体换成另一种字体后对话框的大小按什么比例变化?如何算出这个比例?


How to calculate dialog box units based on the current font in Visual C++
http://support.microsoft.com/kb/q145994/

http://support.microsoft.com/kb/125681


datagrid的问题(.NET技术 ASP.NET)


在datafrid中添加了一列模板列,定义为单选框列,如何把选中的那一列数据的主码取出来,并且传递到另一张页面里?不同页面之间的传值要用 ViewState吗?我要把选中的userID号取出来放在一个变量中,然后调用存储过程删除这条以userID为主码的记录,怎么取出来呢?


不需要ViewState,直接用参数形式传递过去然后接受就可以了
单选的可以参考

<asp:TemplateColumn HeaderText="序号"> <ItemTemplate> <INPUT id=radio onclick=fun_option(this) type=radio value='<%# DataBinder.Eval(Container.DataItem,"UserID") %>' name=radio> </ItemTemplate> </asp:TemplateColumn>

你是在什么时候打开新页面呢?
如果超连接打开,参考如下

<asp:TemplateColumn HeaderText="省市"> <ItemTemplate> <a href='form1.aspx?id=<%# DataBinder.Eval(Container.DataItem,"UserID") %>&name=<%...# DataBinder.Eval(Container.DataItem,"UserName") %>' target="_blank"> <%...# DataBinder.Eval(Container.DataItem,"UserName") %> </a> ItemTemplate> </asp:TemplateColumn>

参考
http://singlepine.cnblogs.com/articles/266538.html

INPUT type="checkbox" name="cbId" value="<%# Eval("ID") %>">

提交后用Request.Form["cbId"]可以得到 "2,323,55,226,884,233" 这样的字符串可以直接用于SQL命令中,如: string sqlStr = "delete from atable where id in (" + Request.Form["cbId"] + ")";

This is actually a known issue that radio buttons in the ItemTemplate are not mutually exclusive:

BUG: Radio Buttons Are Not Mutually Exclusive When Used in a Repeater Server Control
http://support.microsoft.com/?scid=kb;en-us;Q316495

We can workaround this by using either client side script or handling the CheckedChanged event on the server side. Here is the way to handle the CheckedChanged event. Please note that this method requires more postback than client side script does:

1. We can use a Datagrid's to display the rows as Lewis suggested.
2. Create a ItemTemplate column and add a RadioButton to the column. Bind the RadioButton appropriately.
3. Open the ASPX view of the page, add "OnCheckedChanged" attribute to the <asp:RadioButton> element, and make it point to a public handler method defined in the code behind file. Here is a code snippet for example:
In ASPX file
==========

<asp:TemplateColumn HeaderText="RadioCol"> <ItemTemplate> <asp:RadioButton id="RadioButton4" AutoPostBack="True" OnCheckedChanged="RadioButton4_CheckedChanged" runat="server" GroupName="DtFrom"></asp:RadioButton> </ItemTemplate> </asp:TemplateColumn>

In the code behind file
===================

public void RadioButton4_CheckedChanged(object sender, System.EventArgs e) ...{ RadioButton rb=(RadioButton)sender; Response.Write(rb.ClientID.ToString()); //This line is just for test purpose. for (int i =0 ; i <DataGrid1.Items.Count; i++) ...{ ((RadioButton)DataGrid1.Items[i].Controls[0].Controls[1]).Checked= false; } // check the selected radio button rb.Checked= true; }

To get the selected RadioButton when you submit the page, I think you can try the FindCotrol method.

You could also handle the submit button's server-side click event and iterate the rows of the table to find out the selected radio button.


如何在CHtmlVie中调出IE的 添加到收藏夹 和 整理收藏夹?(VC/MFC HTML/XML)


找了一顿只有实现  
HTMLID_FIND    
HTMLID_VIEWSOURCE    
HTMLID_OPTIONS    
 
其它呢?  
另外添加到收藏夹如果不是在网页中点链接应该能传入参数吧?


http://www.microsoft.com/mind/0798/favorites.asp


如何把工程中曾经添加过的ActiveX控件完全删除,使资源视图里ControlBar里也没有相应的图标(VC/MFC 基础类)


以前在工程中加载过MSCOMM控件,在工程中删除控件和相关文件后,关闭工程,删除了.clw,.ncb,.asp,.opt后,重新打开工程,资源视图中ControlBar还有那个控件的图标,只是不好用


You have to manually remove it from the project. Please take care the following things:
1. Back up the existing files.
2. Remove the control from dialogs.
3. Remove the files of wrapper classes for the ActiveX control from the project. As you know, Visual C++ IDE will generate and add wrapper classes for an ActiveX control. For example, we can add classes from the type libary of a control.
4. If the ActiveX control also listed in the controls list of dialog design view, you should close the project, open the <project>.dsw file in notepad, and delete the reference (UUID) to the ActiveX control. For example:
Package=<3>
{{{
{F0D2F21C-CCB0-11D0-A316-00AA00688B10} <<<---------REMOVE THIS LINE
}}}

However, removing the CLSID from the *WORKSPACE* that this pulls the control from *ALL* projects in the workspace. You may need to go back and re-insert the control in the projects where it is still needed.


IHTMLWindow2::execScript时而正常时而不正常是怎么回事(VC/MFC 基础类)


我使用IHTMLWindow2::execScript方法执行若干多句Javascript脚本,
经常出非常诡异的错误,还请各路高人指点:

假设有ABCDEFG七条固定的Javascript语句,每条语句都要使用IHTMLWindow2::execScript来在一个IE控件里执行,结果总会出现一到两条语句执行失败,错误码为“非法参数”-E_INVALIDARG。

此错误的特点:七条语句都有一定几率出错。也就是说,这次运行是C、E出错,下次就有可能是A、F出错,但C、E正常执行。第三次则可能ACE都正确,只有F出错。当然,有时候也会全部七条语句都执行成功。

由此我的判断是Javascript语句没错,IHTMLWindow2::execScript的用法也“应该”没错,但就不知道为什么功能不正常。


看起来是线程同步和函数重入的问题,用CoMarshalInterThreadInterfaceInStream(__uuidof(...)... 那一族函数来传COM指针


在.NET2.0下如何实现web host的功能(.NET技术 C#)


要求:
不需要IIS也可以运行ASP.NET应用程序,因为我需要在WINFORM中潜入ASP.NET应用程序;

说明:
以前在.net1.1下我知道有一个CASSINI是为了解决这个问题,不过哪个太麻烦了,我想问问在.NET2.0下是否有更方便的解决方案


http://msdn.microsoft.com/msdnmag/issues/03/01/CuttingEdge/

http://www.ultidev.com/products/index.htm


关于DLL中导出MFC继承类的问题(VC/MFC 进程/线程/DL)


以前写过几个只导出函数的DLL,现在需要导出MFC继承类(具体的说是CView的继承类,用的是AFX_EXT_CLASS宏定义)
试过以后发现用debug版本编出的dll放在主程序中运行时会出问题,但用release版本的dll运行就不会有问题,不知,在CMyView中仅仅 实现了一个对鼠标的左键点击的消息处理函数,且这个消息处理函数就是弹出一个MessageBox,各位分析一下是什么原因?

貌似Dll是Release版本的,但主程序是debug版本就会出现这个问题,如果两个都是debug版本的,就没有问题了,奇怪的是,为甚会在 ASSERT(pViewClass->IsDerivedFrom(RUNTIME_CLASS(CWnd)))这个地方提示错误,奇怪也哉


no, using multiple versions of MFC (yes, this includes the debug and release version of MFC with the same version number) in different DLL's and passing MFC data between them is not supported. int's, handles, and other non-MFC stuff should work.


为什么 access 在模糊查询的时候 内存益出(Delphi 数据库相关)


Access在执行对包含一些片假名字符的文本字段执行LIKE和instr的时候会有内存溢出错误,这些片假名如下
static string[] strJArray={"ゴ","ガ","ギ","グ","ゲ","ザ","ジ","ズ","ヅ","デ","ド","ポ","ベ","プ","ビ"," パ","ヴ","ボ","ペ","ブ","ピ","バ","ヂ","ダ","ゾ","ゼ"};
你可以自己将数据进行base64/UTF8编码,也可以仅对这几个字符进行自定义编码来节省存储空间。
我的自定义编码函数

static string[] strEArray=...{"Jn0;","Jn1;","Jn2;","Jn3;","Jn4;","Jn5;","Jn6;","Jn7;","Jn8;","Jn9;","Jn10;","Jn11;","Jn12;","Jn13;","Jn14;","Jn15;","Jn16;","Jn17;","Jn18;","Jn19;","Jn20;","Jn21;","Jn22;","Jn23;","Jn24;","Jn25;"}; //用于绕过Access片假名查询内存溢出BUG的编码函数 static public string JEncode(string strToEncode) ...{ for(int i=0;i<strJArray.Length;i++) ...{ strToEncode.Replace(strJArray[i],strEArray[i]); } return strToEncode; } //用于绕过Access片假名查询内存溢出BUG的解码函数 static public string JDecode(string strToDecode) ...{ for(int i=0;i<strJArray.Length;i++) ...{ strToDecode=strToDecode.Replace(strEArray[i],strJArray[i]); } return strToDecode; }

为什么Debug下编译Bitmap *pBitmap = new Bitmap(nWidth, nHeight);通不过(VC/MFC 基础类)


Bitmap *pBitmap = new Bitmap(nWidth, nHeight);

错误消息是:

error C2660: 'new' : function does not take 3 parameters

Release下能正常编译,并且程序没问题。


VC6里面带的debug new 不认识GDI+的类名称形式

删除 cpp 文件 前面的

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

PRB: Microsoft Foundation Classes DEBUG_NEW Does Not Work with GDI+
http://support.microsoft.com/kb/317799


打印网页如何去掉那行URL?及能否在打印完成执行某函数?(Web 开发 JavaScript)


用最常见的打印脚本 self.print(); 打印当前页面。
请教大侠们:
1.打印网页如何去掉那行URL?
打印出来的内容最下方会出现类似 http://localhost:8080/xxxxxxx.jsp?do=... 的url
在某些打印机还会出现这行URL出现在第二页的情况。
请问如何去掉它?

2.能否获知打印完成的事件?在打印完成后欲执行某函数 testS()
应该怎么做?


http://msdn.microsoft.com/library/en-us/IETechCol/dnwebgen/beyondprintpreview.asp

1. 浏览器下拉菜单->文件->页面设置-> 清空页眉页脚。
2. 有一个 onafterprint 事件会被触发


sprintf 中如何在打印数字时加入逗号,像银行的那种如123,456,789.65


There is not a function within the standard library to handle this.
Formatting currency strings is a rather complicated thing to do correctly
due to the format differing wildly from one locale to another. Some
operating systems provide functions to format currencies based on locale
but that is a little OT. If you are doing a platform specific thing then
ask some of the gurus in the newsgroup for your platform. Here is a general
function that formats unsigned numbers based on grouping and a separator.
It could be extended to handle currencies pretty easily; however, if you
have to handle localized currencies, then read your documentation on
setlocale() and localeconv(). These standard functions will provide you
with enough information to format currencies, numbers, dates, and times
with respect to a specific locale.

Anyway, here is a function that will format numbers into a buffer for
you.

void number_to_buffer (unsigned long n, char *buffer, int digits_per_segment, char separator) ...{ unsigned long multiple; /**//* the multiple of 10 to use */ long int cursegment; /**//* largest power of multiple < n */ char *p; /**//* insertion pointer into buffer */ long int digits; /**//* current segment */ int nsegments; /**//* number of three digit segments */ char formatstr[32]; /**//* the format string for each segment */ /**//* Set up our parameters. */ p = buffer; *p = '/0'; multiple = pow(10, digits_per_segment); /**//* Set up a printf-style format string to handle zero padding * each segment (i.e., formatstr = "%03d"). */ sprintf(formatstr, "%%0%dd", digits_per_segment); /**//* Figure out how many segments we have in n. */ nsegments = ((int)log10((double)n)) / digits_per_segment; if (nsegments > 0) ...{ /**//* * `n'' requires more than one segment, so handle each * segment separately within a loop. We have to handle the * first segment separately since it doesn't require zero * padding. We also prime ``cursegment'' as the highest * power of ``multiple'' that is less than or equal to * ``n'' here. */ cursegment = pow(multiple, nsegments); digits = n / cursegment; p += sprintf(p, "%ld", digits); *p++ = separator; n -= (digits * cursegment); cursegment /= multiple; --nsegments; /**//* Spin for the remaining powers of 1000 within n. */ while (nsegments != 0) ...{ digits = n / cursegment; p += sprintf(p, formatstr, digits); *p++ = separator; n -= (digits * cursegment); cursegment /= multiple; --nsegments; } /**//* Place the final trailing digits on. */ sprintf(p, formatstr, n); } else ...{ /**//* n only requires one segment so no leading zeros are * necessary. */ sprintf(p, "%ld", n); } }

It isn't exactly the safest function in the world since it will gladly
clobber buffers that are too short, but it does the job. Here is a little
example of using it:

number_to_buffer(12012012UL, buffer, 3, ',');
printf("%s/n", buffer);
/* prints 12,012,012 */

You'll have to extend it to handle negative numbers (if necessary). Also
note that -1.23 dollars is usually displayed as ``($1.23)'' as opposed
to ``-$1.23''. I guess the handling will depend on how technically correct
you have to be.

On Windows, you can also use GetNumberFormat to format numbers

TCHAR szBuff[20];
TCHAR szNum[] = "10000";
NUMBERFMT nf;
nf.NumDigits = 0; // no decimal
nf.LeadingZero = 0;
nf.Grouping = 3;
nf.lpDecimalSep = ".";
nf.lpThousandSep = ","; // Thousand separator
nf.NegativeOrder = 0; // This will display as (10,000) if it is a -ve
value. See LCTYPE constants for more info.

int iRet = GetNumberFormat(NULL, 0, szNum, &nf, szBuff, sizeof(szBuff) );
TRACE("Return Value : %d Buffer: %s/n", iRet, szBuff);

You can use the GetLocaleInfo API to determine the thousand separator.
TCHAR szThousandSep[10];
GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, szThousandSep,
sizeof(szThousandSep));


怎么写入config配置文件?(.NET技术 C#)


我知道可以用下面的方法读取config文件
1.打开命名空间
using System.Configuration;
2.读取示例
string dbhost=ConfigurationSettings.AppSettings["DBHost"].Trim();
string dbname=ConfigurationSettings.AppSettings["DBName"].Trim();
string dbuser=ConfigurationSettings.AppSettings["DBUser"].Trim();
string dbpass=ConfigurationSettings.AppSettings["DBPass"].Trim();

请教各位大虾有没有类似的方法将配置信息写入


http://ryanfarley.com/blog/archive/2004/07/13/879.aspx


在定制IE鼠标右键菜单时候碰到的一个很奇怪的问题(Web 开发 JavaScript)


我要定制一个IE浏览器的鼠标右键菜单,出是出来了,可是当我在菜单上移动的时候,如果很快的移动多次,不是点击,仅仅是移动,菜单就会自动消失,我还没有写让菜单消失的代码呢。

可以拷贝代码试试,就是把鼠标在那个菜单上迅速的移动,菜单就会自动消失,很奇怪的。

如果我吧菜单里面的onmouseover和onmouseout去掉的话,就不会发生,但是这样一来就不像菜单了

代码如下:

<html> <head> <style type="text/css">... body,td,input,textarea {...}{font-size:9pt} </style> <script type="text/javascript" language="JavaScript">... function showContextMenu( event )...{ var mouseMenu = window.createPopup(); var w = 116; var h = 132; var x = event.clientX; var y = event.clientY;     //写入右键菜单 mouseMenu.document.open(); mouseMenu.document.write("<head>"); mouseMenu.document.write(" <style type='text/css'>"); mouseMenu.document.write(" body,td {font-size:9pt;font-family:Arial;}"); mouseMenu.document.write(" BODY {margin:0px;border:0px}"); mouseMenu.document.write(" TABLE.Menu {border-top:window 1px solid;border-left:window 1px solid;border-bottom:buttonshadow 2px solid;border-right:buttonshadow 2px solid;}"); mouseMenu.document.write(" TD.MouseOver {background-color:highlight;color:highlighttext;cursor:default;}"); mouseMenu.document.write(" TD.MouseOut {cursor:default;}"); mouseMenu.document.write(" </style></head>"); mouseMenu.document.write(" <body scroll='no' onConTextMenu='event.returnValue=false;' bgcolor='D4D0C8' marginheight='0' marginwidth='0'>"); mouseMenu.document.write(" <table class=Menu width='115' border='0' cellpadding='0' cellspacing='0'>"); mouseMenu.document.write(" <tr disabled><td width='115' class=MouseOut onMouseOver=this.className='MouseOver'; onMouseOut=this.className='MouseOut' unselectable='on'>&nbsp; &nbsp; 剪切<font style='font-size: 8pt'>(<u>T</u>)</font></td></tr>"); mouseMenu.document.write(" <tr><td class=MouseOut onMouseOver=this.className='MouseOver'; onMouseOut=this.className='MouseOut' unselectable='on'>&nbsp; &nbsp; 复制<font style='font-size: 8pt'>(<u>C</u>)</font></td></tr>"); mouseMenu.document.write(" <tr><td class=MouseOut onMouseOver=this.className='MouseOver'; onMouseOut=this.className='MouseOut' unselectable='on'>&nbsp; &nbsp; 粘贴<font style='font-size: 8pt'>(<u>P</u>)</font></td></tr>"); mouseMenu.document.write(" <tr><td class=MouseOut onMouseOver=this.className='MouseOver'; onMouseOut=this.className='MouseOut' unselectable='on'>&nbsp; &nbsp; 删除<font style='font-size: 8pt'>(<u>D</u>)</font></td></tr>"); mouseMenu.document.write(" <tr><td><hr size='2'></td></tr>"); mouseMenu.document.write(" <tr><td class=MouseOut onMouseOver=this.className='MouseOver'; onMouseOut=this.className='MouseOut' unselectable='on'>&nbsp; &nbsp; 查找和替换<font style='font-size: 8pt'>(<u>F</u>)</font>...</td></tr>"); mouseMenu.document.write(" <tr><td><hr size='2'></td></tr>"); mouseMenu.document.write(" <tr><td class=MouseOut onMouseOver=this.className='MouseOver'; onMouseOut=this.className='MouseOut' unselectable='on'>&nbsp; &nbsp; 属性<font style='font-size: 8pt'>(<u>A</u>)</font></td></tr>"); mouseMenu.document.write(" </table></body>"); mouseMenu.document.close(); //显示 mouseMenu.show( x,y,w,h,document.body );     //屏蔽IE右键菜单 return false; } </script> </head> <body oncontextmenu="return showContextMenu(event);"> </body> </html>

1 check your positioning to see if the window is out of sight
2 check if the object is reclaimed by the garbage collector. Make the mouseMenu object global to extend its lifetime.

see also
http://msdn.microsoft.com/workshop/author/dhtml/popupmenu.asp


VC6的IDE + VC2003的编译器/SDK,合并后的调试问题(VC/MFC 进程/线程/DLL)


合并之后,VC6的IDE不能识别VC2003编译之后的调试信息(在.pdb中),结果不能调试


用debug tools for windows,或者升级IDE


在VC写的程序里向网页中的Flash中发送某些命令的实现方法(专题开发/技术/项目 多媒体/流媒体开发)


http://www.macromedia.com/cfusion/knowledgebase/index.cfm?id=tn_14280
http://www.codeproject.com/com/jscalls.asp


请问 51 单片机如何产生 38KHz 的脉冲?(其他开发语言 汇编语言)


AT89C2051, 12M 晶振

我想让红外管以 38KHz 的频率发射红外线,类似遥控器,
程序语句应该怎样写才能精确达到呢?


用个定时器做中断啊!

下面的算法在PIC 16F88微处理器以4兆赫模式运行时产生一个33赫的脉冲。
http://spaces.msn.com/members/jiangsheng/Blog/cns!1pVUmC6mid-3zVpLZNQTgtuw!198.entry

近似调整,方法类似于系统时间的计算,精确很难。


怎样远程显示本机CPU的占用率?(.NET技术 VC.NET)


Web应用程序怎样与本地应用程序结合?

我要在浏览器上实时显示本地机器上的应用程序的数据,如本地的一个应用程序中测出来的CPU的占用率,我突然发现microsoft似乎故意避免了这两种类型应用程序的结合。


se WMI

In WinXP and higher, you can use the IWbemRefresher with the Win32_PerfFormattedData_PerfProc_Process class.

IN W2K and below, you can use a hand-crafted poller that keeps querying Win32_PerfRawData_PerfProc_Process, and you will have to add the "math logic" to your application.

'Get % Processor Time for a process ' after the script is started, launch Task Manager to see the result ' process name to monitor sProcessName = "taskmgr" 'Connect to Local Machine set wmi_service = _ GetObject("winmgmts:{impersonationlevel=impersonate}!/root/cimv2") sObjectPath = "Win32_PerfRawData_PerfProc_Process.Name=" _ & chr(34) & sProcessName & chr(34) wscript.echo "Monitoring " & sObjectPath set perf_instance1 = wmi_service.get( sObjectPath ) N1 = perf_instance1.PercentProcessorTime D1 = perf_instance1.TimeStamp_Sys100NS do 'Sleep for one second = 1000 ms wscript.sleep(1000) set perf_instance2 = wmi_service.get( sObjectPath ) N2 = perf_instance2.PercentProcessorTime D2 = perf_instance2.TimeStamp_Sys100NS ' CounterType - PERF_100NSEC_TIMER ' Formula = ((N2 - N1) / (D2 - D1)) x 100 if ( 0 = (D2-D1) ) then wscript.echo "divide by zero" else PercentProcessorTime = ((N2 - N1) / (D2 - D1)) * 100 wscript.echo "% Processor Time = " , PercentProcessorTime end if N1 = N2 D1 = D2 'looping for 30 seconds i = i + 1 loop until i = 30 WScript.Echo "Finished"

WMI can be used on a remote computer, see Remote Administration with WMI ( http://www.windowsitpro.com/Windows/Article/ArticleID/37596/37596.html)
You can also use .Net remoting, or write a B/S application.

如果用推的技术,那么,直接用数据库作为中介就可以了,也就是本地应用程序将数据更新到数据库,而web应用程序将数据推到客户浏览器


asp.net与IE, FireFox, NetScape,Opera等浏览器的问题(.NET技术 ASP.NET)


用asp.net做的网页,在IE中浏览正常,但用FireFox,NetScape,Opera等浏览器会不正常,比如DropDownList, ListBox宽度和高度会变小, DataGrid网络线的颜色与IE中的也不一样等等...


ASP.NET
From Wikipedia, the free encyclopedia

The framework's browser detection feature sometimes incorrectly identified web browsers other than Microsoft's own Internet Explorer as "downlevel" and returned HTML/JavaScript to these clients that was crippled or broken. However, in version 2.0, all controls generate valid HTML 4.0, XHTML 1.0 (the default), or XHTML 1.1 output, depending on the site configuration, detection of standards-compliant web browsers is more robust, and support for Cascading Style Sheets is more extensive.

ASPX1.1里面把非IE浏览器都定义在html3.2,而ie则是html4.0所以浏览样式有很大差别。
可以自己改一下在webconfig里加段代码

<browserCaps> <case match="^Mozilla/5/.0 /([^)]*/) (Gecko/[-/d]+)(?'VendorProductToken' (?'type'[^//d]*)([/d]*)/(?'version'(?'major'/d+)(?'minor'/./d+)(?'letters'/w*)))?"> browser=Gecko <filter> <case match="(Gecko/[-/d]+)(?'VendorProductToken' (?'type'[^//d]*)([/d]*)/(?'version'(?'major'/d+)(?'minor'/./d+)(?'letters'/w*)))"> type=${type} </case> <case> <!-- plain Mozilla if no VendorProductToken found --> type=Mozilla </case> </filter> frames=true tables=true cookies=true javascript=true javaapplets=true ecmascriptversion=1.5 w3cdomversion=1.0 css1=true css2=true xml=true tagwriter=System.Web.UI.HtmlTextWriter <case match="rv:(?'version'(?'major'/d+)(?'minor'/./d+)(?'letters'/w*))"> version=${version} majorversion=0${major} minorversion=0${minor} <case match="^b" with="${letters}"> beta=true </case> </case> </case> </browserCaps>

关于控件保存为图片(metafile)(VC/MFC 图形处理/算法)


ondraw函数如下:

HRESULT OnDraw(ATL_DRAWINFO& di) ...{ HMETAFILE hmf; HBRUSH hBrush ; HPEN hPen; HDC hdc,hdcMeta; hdc=di.hdcDraw; RECT& rc = *(RECT*)di.prcBounds; hdcMeta= CreateMetaFile("c://Documents and Settings//meta.wmf") ; hBrush= (HBRUSH)GetStockObject(NULL_BRUSH); hPen=(HPEN)GetStockObject(BLACK_PEN); SelectObject(hdcMeta,hPen); SelectObject(hdcMeta,hBrush); Rectangle(hdcMeta, rc.left,rc.top, rc.right,rc.bottom); MoveToEx (hdcMeta, rc.left,rc.top,NULL); LineTo(hdcMeta,rc.right,rc.bottom); MoveToEx(hdcMeta, rc.left,rc.bottom,NULL); LineTo(hdcMeta,rc.right,rc.top); hBrush= CreateSolidBrush (RGB (0, 0, 255)) ; SelectObject (hdcMeta, hBrush) ; Ellipse (hdcMeta, rc.left+20,rc.top+20, rc.right-20,rc.bottom-20*x); hmf = CloseMetaFile (hdcMeta) ; ::PlayMetaFile(hdc,hmf) ; return 0K; }

现在问题是,控件放到IE里面完全正确,但把保存的图片放到word里面,却出现了一个216*216的白色背景,让需要的主界面显得很小了。还有,如果调整屏幕的分辨率,该图片里面的我的控件部分变大了,但背景部分不变,仍然是216*216。不知道为什么


Most apps require an Aldus Placeable Metafile format, which has an extra 22-byte header.
see http://msdn.microsoft.com/archive/en-us/dnargdi/html/msdn_enhmeta.asp


如何调试全屏的DX程序(专题开发/技术/项目 游戏开发)


每次在VC6中打断点进行调试,弹出来以后就无法再进入游戏了,请问有什么好的方法吗


remove debugging
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsdebug/html/vctskInstallingRemoteDebugMonitor.asp

做一个窗口版本的用来调试.或者找另外的显示途径:将感兴趣的信息写到文件中,弹出对话框等等

双头显卡,双显示器调试

窗口方式调试程序无误后,再转换成全屏的模式


DLL中无法执行CoInitializeEx.(VC/MFC 进程/线程/DLL)


在Exe中某函数有如下语句:
HRESULT hres=CoInitializeEx(0,COINIT_MULTITHREADED) 可以顺利执行初始化。
但是将此函数移植到DLL中后,在VB中调用这个DLL某函数时。CoInitializeEx 会初始化失败。

在DLL中将 CoInitializeEx 改成 hres=CoInitializeEx(0,COINIT_APARTMENTTHREADED);
就可以Success了。但是
hres=CoInitializeSecurity(
NULL,-1,NULL,NULL,RPC_C_AUTHN_LEVEL_CONNECT,
RPC_C_IMP_LEVEL_IDENTIFY,NULL, EOAC_NONE, 0);
hres返回又失败了。


你不应该在DLL中初始化COM。
COM的初始化是以线程为单位的。通常你应该让调用DLL的应用程序来初始化COM以避免冲突。你的DLL自动初始化COM的话,会使得应用程序不能使用一些不同套间的COM组件


gdi+ 的问题,msdn 中的函数为什么我找不到?(VC/MFC 图形处理/算法)


platform sdk 也装了,但是就是找不到下面这个函数....

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdicpp/GDIPlus/GDIPlusReference/Classes/BitmapClass/BitmapGetHistogramMethods/ConvertFormat.asp

msdn 上的信息

Stock Implementation gdiplus.dll
Header Declared in GdiplusBitmap.h, include gdiplus.h
Import library gdiplus.lib
Minimum availability GDI+ 1.1
Minimum operating systems Windows 98, Windows XP, Windows 2000, Windows NT 4.0 SP6

可是我去那里获得这个gdi+ 1.1呢?


Neither the GDI+ 1.1 SDK, nor the GDI+ 1.1 runtime has been shipped. Although it is not the "Official 1.1 Gdiplus Release", all of the new API functions described in the PlatformSDK are available with the gdiplus.dll that is installed with Office 2003. Microsoft uses the new functionality in Office 2003.

The functions are fully documented in the Platform SDK. If you want to write code to test out the new API's, just get hold of the dll. However, it is not "legal" to redistribute the version that comes with Office.


接口实现了IObjectWithSite后,无法在VBScript脚本中创造对象的疑问(VC/MFC ATL/ActiveX/COM)


做了个BHO,因为IE上下文菜单的缘故,想在脚本中也能调用这个组件,但发现一个接口一旦实现了IObjectWithSite接口后,就无法在脚本创建对象。


IE的site和script的不一样的,在setsite那里设断点看看你的代码怎么处理错误的


PostMessage里指针参数的销毁问题(VC/MFC 进程/线程/DLL)


CString *pstr = new CString("Param");
PostMessage(hWnd, WM_XXX, (WPARAM) pstr, 0);

以下是我能想到的几个解决方案,但都不太好,希望各位指点。
或是你对以下方案的改进意见和不同看法也行。谢谢:)

解决方案1. 在消息处理函数中处理。
例:
LRESULT OnXXX(WPARAM wParam, LPARAM lParam)
{
CString *pstr = (CString*) wParam;

// Handler Message

delete pstr; pstr = NULL;
}
缺陷。1.麻烦。
2.如果目标窗口不处理该消息,则造成内存泻漏。
(在类似于广播消息的设计中,可能是会有种情况,
如:我把消息发给n个窗口,它们可以关心它,也可以简单的忽略它。这种情况就很郁闷。)

解决方案2. 使用SendMessageCallback。

它工作得很好。但是有一个问题:SendMessageCallback是一个类
SendMessage的处理。
在跨线程的消息传递中,它把消息(例:WM_MSG_A)放到目标线程的
SendMessage队列。
那么当目标线程在发消息给另一个线程时,它会在SendMessage返回之
前,就执行 WM_MSG_A 的处理。

这一点不是我所需要的。我希望它能像PostMessage一样被处理。

解决方案3 创建垃圾回收机制
缺陷:清理的周期较难把握。太长了消息多的话那个内存。。。看着心疼。
太短了的话,有可能消息还没被处理,数据就被销毁了。害怕。:)

现在我在试着用SetWindowsHook。

Hook上WH_GETMESSAGE

在发送时进行转义 如提供
PostMessageEx(uMsg, ...)
{
pPacketData = new CPacketData;
pPacketData->uMsg = uMsg;
.....

PostMessage(WM_PACKET, (WPARAM) pPacketData, 0);
}

然后在在HookProc里对消息进行处理

if (WM_PACKET == pMsg->message)
{
pMsg->message = pPacketData->uMsg;
....

::TranslateMessage(pMsg);
::DispatchMessage(pMsg);

// 释放资源。
}

这样是可以的,但是存在一个问题:

SetWindowsHookEx(WH_CALLWNDPROC, MyCallWndProc, ::AfxGetInstanceHandle(), GetCurrentThreadId());

时,只能对一个线程进行Hook,那其他线程就无效了。
使用全局的Hook可能可以,不过那样就麻烦很多了。
是不是还得建个dll啊:(汗~而且还影响到其他进程:(。

/*******问题******
有没有办法可以Hook当前进程的所有线程啊?包括之后启动的线程。
**************/

/***********问题**************
而且有一个问题SetWindowsHook会不会受系统影响啊?如你不是管理员,杀毒软件之类。会吗?
*****************************/

现在关键的问题是:“哪里是消息处理结束的时候”?
不能在 消息处理函数的最后, 因为像“方案1”提到的,目标窗口可以不处理这条消息。

To meicaikourou: 我的意思不是说PostMessage带的参数不够多。
而是怎么来实现PostMessageEx的问题。目前的这种SendMessageCallback表面上是可以解决这个问题。但是:像我在第一楼说的,“SendMessageCallback是一个类SendMessage的处理。”

看过《windows核心编程》中“Windows消息处理”那一章,或相关内容的都应该知道。
当ThreadA SendMessage 到ThreadB 的时候,如果此时ThreadB在 SendMessage到 ThreadC,
那么在ThreadB 的SendMessage返回之前就会执行ThreadA 发过来的消息的响应处理。
也就是说它的处理被打断了。

而PostMessage就会等ThreadB 的SendMessage处理完,之后走到一个GetMessage类的函数才会被取出来处理。

虽说SendMessageCallback是立即返回,但它的底层的调用是类似SendMessage的(即把消息放在目标线程的SendMessage队列里)。所以会存在同样的问题。

这也是SendMessageCallback这种解决方案唯一一点不好的地方。

/*************
所以现在的问题是,寻找另一种解决方案。
***********/


自定义一个类,数据结构为环形链表,静态创建该类的一个对象,环链大小根据你的需求而定。每次postMessage,环头向前移动,程序退出时回 收该环.环链不会用多少资源吧,我来给你假设一下,你的PostMessage(),在主线程那里积累到4000个够了吧,你静态创建一个环链,它有 4000个节点,对于char* 的param而言,4000个node不用多少空间。
环头指向第一个有用的node,每次PostMessage,环头前移一个node,把参数考入。因为是环状的,在运行期间不必要 delete,结束时候,把环链对象销毁就行了。
4000只是个数字,随便你定了,满足需要就行,但是这个环链的类要自己写

我说的4000是指PostMessage()在消息队列中的积累,是未处理消息队列的长度,不是postmessage多少次。因为主线程会处理掉message,即使你PostMessage再快也不会使消息队列达到无穷长。
结束时候,我指的是程序退出时,比如在,WM_DESTORY中销毁该链环。
我打个简单类你看下
//参数结构体节点
struct ParamNode
{
char szParam[LENGTH];//char*参数
ParamNode* pPre;//前节点
ParamNode* pNex;//后节点
ParamNode() //构造函数
{
szParam[0]=0
pPre = NULL;
pNex = NULL;
}

};
//参数链环类
class CParamRing
{
public:
CParamRing(int RingLen);//构造函数,RingLen为需要的ParamNode节点数,比如4000,在构造函数中要使得这RingLen个Node首尾相连,成为环链表。
~CPrarmRing();//析构函数,删除掉在构造函数中new 的ParamNode
ParamNode* GetValidNode();// 返回可用的节点,比如m_Head,
private:
m_Head;//当前节点
};

在应用程序初始化时,
CParamRing* pParamRing = new CParamRing(4000);
......
ParamNode* pNode = GetValidNode();;
strcpy(pNode->szParam,消息参数);
PostMessage(hWnd,MESSAGE,(WPARAM)pNode,LPARAM);
.....
在WM_DESTROY中
delete[] pParamRing;就可以了

SendMessageCallback是很好用。但是要注意:
1. 同一线程
如果你SendMessageCallback的目标窗口属于本线程的话,那它实际上是直接调用窗口处理函数(像 SendMessage)一样。所以如果你的消息处理中有死循环的话会被堵住。(不像PostMessage)
2.跨线程
除了我在楼上说的问题之外,还有一个问题,当你调用SendMessageCallback的线程在Callback函数被调用之前结束了的话(Thread has ended),那么那个Callback函数是不会被调用的。注意这一点!

if you are allocating and freeing data crossing DLL boundaries, you can get into trouble. In this case, use the COM memory allocation.

You can also encounter fragmentation by constantly allocating and freeing memory. A memory pool is suggested.

On page 473 of "Advanced Windows" in Chapter eleven - Windows messages and Asynchronous input - it suggests using the Win32 function SendMessageCallback for passing message between two threads in the same process, and the Win32 function SendMessageTimeout for passing message between two threads in different processes.


将网页里如&#27827的字符在C#程序里转换成相应编码的字(.NET技术 C#)


http://msdn.microsoft.com/library/en-us/vbcon/html/vbtskProtectingAgainstScriptExploitsInWebApplication.asp


寻找支持zoom和scroll的CWnd继承类(VC/MFC 界面)


既然不能从CStatic继承,我也就不想多麻烦大家了
如果谁知道有现成代码可以实现
zoom和scroll功能的请告诉我,谢谢

但是不能从CView继承,因为CView本身不能单独创建,它必须和框架类集成在一起,所以没法使用CView。

顺便请教一下各位,其实这个程序就是想实现一个能够放在DockBar里的支持Zoom、Scrool的View
可是CView无法单独创建,我不知道如何将一个Cview放到DockBar里,各位有什么好办法么?


我的做法是在dockbar里面放frame
www.codeproject.com/docking/dockview.asp

												

Jiangsheng的CSDN Digest(May 15, 2006)相关推荐

  1. Jiangsheng的CSDN Digest(March 4, 2006)

    为了便于搜索,这里尽可能保留了论坛上讨论的原文,但是这并不表示本人赞同帖子中的表述方式和观点. CSDN 讨论总结系列: Jiangsheng的CSDN Digest (Jan 21 2006)( h ...

  2. Jiangsheng的CSDN Digest (Oct 2005)

    CSDN 讨论总结系列: Jiangsheng的CSDN Digest (Dec 2005)(http://blog.csdn.net/jiangsheng/archive/2005/12/24/56 ...

  3. http://blog.csdn.net/KBUG/archive/2006/10/30/1357009.aspx

    http://blog.csdn.net/KBUG/archive/2006/10/30/1357009.aspx

  4. 做为一个中国的ITer,你感到耻辱吗?看CSDN的“软件中国2006风云榜之10大最具创新性技术”...

    http://news.csdn.net/n/20070105/100348.html 10大最具创新性技术(除年度最佳外,其余按首字拼音顺序排列) 入围名单(按首字拼音顺序排列): 达梦数据库DM ...

  5. 感谢CSDN提名我候选2006最有价值博客,感谢朋友们的投票

    我的推荐文字: J2EE领域资深专家,对企业级系统架构,设计模式,敏捷开发等方面有深入研究.长期从事电子政务领域的应用开发,开发项目涉及企业门户,内容管理,行政审批,公文流转,公文交换,绩效管理,企业 ...

  6. Win32 .Net QA

    CSDN 讨论总结系列: Jiangsheng的CSDN Digest (Dec 2005)(http://blog.csdn.net/jiangsheng/archive/2005/12/24/56 ...

  7. Win32 .Net QA

    CSDN 讨论总结系列: Jiangsheng的CSDN Digest (Dec 2005)(http://blog.csdn.net/jiangsheng/archive/2005/12/24/56 ...

  8. Win32 .Net QA 200509

    CSDN 讨论总结系列: Jiangsheng的CSDN Digest (Dec 2005)(http://blog.csdn.net/jiangsheng/archive/2005/12/24/56 ...

  9. VC/MFC QA 200407

    CSDN 讨论总结系列: Jiangsheng的CSDN Digest (Dec 2005)(http://blog.csdn.net/jiangsheng/archive/2005/12/24/56 ...

最新文章

  1. oracle取非空,求一条sql,返回分组后,空值取最近一条非空值,非空值取本身
  2. 用mpvue实现的微信小程序版cnode社区
  3. 【 FPGA 】7 Series FPGA中对MUX的设计指导
  4. python 跳出多重循环
  5. linux 重名名、删除文件操作
  6. ios 学习札记 细节(三)
  7. 前端学习(904):同步任务和异步任务执行区别
  8. laravel 自带的用户登录视图路径_Laravel实现找回密码及密码重置,详细操作
  9. [Web Chart系列之五] 4. 实战draw2d(Raphael)之取消Chrome中Label Text 全部选中
  10. svn主干开辟分支、分支合并到主干
  11. 摘自缪雪峰的博客的JavaScript个人笔记(3)
  12. 红旗linux mysql_请问红旗Linux下,安装Mysql时,应该下载mysql 的哪一种rpm包?谢谢
  13. 【Oracle】利用trace文件重建控制文件
  14. mysql gis vs postgis_mysql空间扩展VSPostGIS
  15. python从入门到放弃pdf下载-《Python3从入门到放弃》视频教程
  16. idea2016 android genyomtion,Android Studio Genyomtion配置
  17. LightOj 1088 - Points in Segments (二分枚举)
  18. java since,javadoc:@version和@since
  19. Iphone开发(7) 太你妈辛苦了
  20. SQL注入-验证码处理

热门文章

  1. C语言学习笔记10-指针(动态内存分配malloc/calloc、realloc、释放free,可变数组实现;Tips:返回指针的函数使用本地变量有风险!;最后:函数指针)
  2. linux开放端口命令
  3. The request client is not a secure context and the resource is in more-private address space private
  4. [Python]Python oop的私有制
  5. 关于指数函数等价无穷小的小发现!
  6. 开发人员(程序员)怎么写技术文档
  7. 华三交换机配置多个镜像口_H3c交换机配置端口镜像详情
  8. Java中原生(native)函数的用法
  9. Singleton bean creation not allowed while singletons of this factory are in destruction (Do not requ
  10. MySQL必知必会汇总