Jiangsheng的CSDN Digest(July 8, 2006)

来源:互联网 发布:我的世界java下载 编辑:程序博客网 时间:2024/05/20 16:12

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


如何获得与登陆用户名?(.NET技术 ASP.NET )


一个BS项目,部署在域服务器上。当域中某个用户成功登录域后,系统以域用户登录系统。现在的问题是,我怎样在程序中获得域用户的相关信息?


http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q315736
http://support.microsoft.com/kb/315158/

System.Security.Principal.WindowsIdentity

http://community.csdn.net/Expert/topic/4838/4838968.xml?temp=8.127993E-02

1. 使用integrated windows anthentication
在IIS中設置: 內容 -> 目錄安全設定 -> 編輯(匿名存取及驗證控制) -> 勾掉匿名存取,勾選整合的windows驗證

2. 獲取用户的AD帳號
用 HttpContent.Current.User.Name.Identity当前得到windows用户名。


使用WebBrowser嵌入网页,怎样可以读到此页面中的javascript对象,如此对象有自定义属性怎么读取?(.NET技术 C# )


使用WebBrowser嵌入一个网页,里面的javascrip中的一个对象的操作有如下代码:
var a=new Object();
a.a=123;
a.b="456";
a.c=13.33;
另有一个函数
function ret_a()
{
return a;
}
我使用WebBrowser中的一个方法来调用这个函数,读取javascrip变量a的值:
object obj_a=webBrowser1.Document.InvokeScript("ret_a");
后面我就不知道如何去读取a里面的a,b,c三个属性的值了。
我查了一些帮助,相关的一些类有:
mshtml.IHTMLObjectElement
Microsoft.JScript.JSObject
可是我还是不知道如何去应用这些类。

请问,我如何能实现读取a里面的a,b,c三个属性


用脚本的话是webBrowser1.Document.script.a.a
不过后期绑定的话要invoke,比较麻烦
参考http://www.codeproject.com/useritems/How2LateBinding.asp



在C++Builder中如何检测光驱中有没有光盘?(C++ Builder 基础类)


char volname[255],filename[100]; // buffer[512];
DWORD sno,maxl,fileflag;
if(!(GetVolumeInformation("H:",volname,255,&sno,&maxl,&fileflag,filename,100)))
// 如果返回值为假
//Memo2->Lines->Add("CD-ROM中未发现光盘!");
MessageBox(Application->Handle," CD-ROM中未发现光盘!","提示",MB_ICONINFORMATION);
else
// 如果返回值为真
{
Memo2->Lines->Add("CD卷标为:" + String(volname));
Memo2->Lines->Add("CD序号为:" + String(sno));
}
 

AnsiString Drive;
for (int i=3;i<26;i++)
{
Drive=AnsiString(char(i+64))+"://";
if (GetDriveType(Drive.c_str())==DRIVE_CDROM)
{
SetErrorMode(SEM_FAILCRITICALERRORS);
if (DiskSize(i)==-1)
ShowMessage("没光盘");
else
ShowMessage("有光盘");
}
}
 

http://msdn.microsoft.com/msdnmag/issues/04/01/CQA/


如何得到字符集名称? (VC/MFC 基础类)


如何通过LOGFONT结构中的lfCharSet值得到字符集的名称?


EnumFontFamiliesEx


delphi5.0可以调用C#写的webservice接口吗?(Delphi 网络通信/分布式开发 )


d6 up 在 new -> webservice -> wsdl importer 可以生成pascal的soap接口定义文件

http://www.topxml.com/Delphi%20SOAP/rn1-6527-default.aspx
http://community.borland.com/article/0,1410,27982,00.html
http://community.borland.com/article/0,1410,27513,00.html

用VB做了个dll,封装了soap连接我们的webservice的方法


MSN Messenger是怎么知道有新邮件到达的?(.NET技术 C# )


Hotmail doesn't use POP / IMAP. Instead, it uses a WebDAV based protocol (aka HTTPMail). There is a provider under development at SourceForge at http://sourceforge.net/projects/jhttpmail/


如何去掉框架窗口的立体边框? 好像MFC默认设置了WS_EX_CLIENTEDGE(VC/MFC 基础类)


在PreCreateWindow里去掉了这种风格,但是窗口还是老样子,郁闷!
BOOL CMainWindow::PreCreateWindow(CREATESTRUCT& cs){

cs.dwExStyle&=~WS_EX_CLIENTEDGE;

return CFrameWnd::PreCreateWindow(cs);
}
 


cs.dwExStyle will be modified in CFrameWnd::PreCreateWindow to add the WS_EX_CLIENTEDGE style.
Remove this style after CFrameWnd::PreCreateWindow

void CMainFrame::OnShowWindow(BOOL bShow, UINT nStatus)
{

this->ModifyStyleEx(WS_EX_CLIENTEDGE,0,SWP_NOSIZE);
}


请问如何在SQL2005中获得系统所有数据库,指定数据库的所有表以及指定数据库的指定表的所有字段,以及字段的类型,长度等 (MS-SQL Server 新技术前沿 )


Schema Discovery

Schema discovery allows applications to request managed providers to find and return information about the database schema of the database a given connection is connected to. Different database schema elements such as tables, columns and stored-procedures are exposed through the GetSchema methods of each provider's Connection class. For more information, see
http://msdn2.microsoft.com/en-us/library/kcax58fh.aspx

select * from sys.databases
select * from information_schema.tables
select * from information_schema.columns

SELECT c.[id], object_name(c.[id]) obj_name, c.colid, c.[name], t.[name] type, c.length, c.isnullable, c.xprec, c.xscale,
(select m.[text] from dbo.syscomments m where m.[id]=c.cdefault) defaultvalue,
(select p.[value] from sys.extended_properties p where p.major_id=c.id and p.minor_id=c.colid and p.[name] = 'MS_Description' ) description
FROM dbo.syscolumns c, dbo.systypes t
WHERE (c.name <> 'dtproperties')
AND c.xusertype = t.xusertype
ORDER BY obj_name, c.colid
 


C++里面的const函数在C#里面有相似的用法吗?(.NET技术 C# )


http://msdn.microsoft.com/msdnmag/issues/04/04/NETMatters/

如果你是防止通过类的成员函数来修改类的对象,那么可以如下做:
如果是值类型,不需要做任何事情,对于值类型变量的赋值是进行copy的。

如果是引用类型,则需要做处理,即需要用对象的copy来进行返回。
只读属性可能类似于你要的
class CC
{
int m_nNum;
public int Num {
get{
return m_nNum;
   }
}
}
不过直接用只读属性也有问题,即属性的类型是引用类型的时候(除string外),也可以进行变相修改,因此也要作相应的处理。
参看
http://blog.csdn.net/Knight94/archive/2006/06/04/772886.aspx


关于activex界面的问题 (VC/MFC ATL/ActiveX/COM)


制作了一个activex控件,控件是这样做的,在create事件里面我产生了9个static,然后显示,可是在加到vb工程里面的时候呢,不运行他就不会出现这几个创建的static,运行以后才能出现,请问我该在哪个事件里面创建这几个static并且显示,才能在调试的时候也能出现这几个static


In MFC there is COleControl::AmbientUserMode(). In ATL there is CComControl::GetAmbientUserMode(). You can also implement IOleControl::OnAmbientPropertyChange and watch for DISPID_AMBIENT_USERMODE property.

After IOleObject::SetClientSite is called, Ambient properties can be queried off of from the client site pointer. You can override the IOleObject::SetClientSite implementation(COleControl::OnSetClientSite/CComControl::SetClientSite) , forward the call to the inherited implementation, then access ambient properties.
Reference
http://support.microsoft.com/kb/195188


在dll中部分导出抽象类,编译通过,exe调用时报异常(VC/MFC 基础类 )


You should not export abstract class from DLLs. The difference between compile options may cause inconsistency for the same declaration.

Reference
http://support.microsoft.com/kb/q168958


如何在vc中使用类似于 IMimeBody 这样的组件接口,来对 .eml 文件进行处理(VC/MFC ATL/ActiveX/COM )


这样的组件还有 IMimePropertySet,IMimeMessage 等!在 msdn 中有很多,但是就是没有例子,只有函数的说明!

网上有个例子是对 OutLook 中的收件箱/发件箱/中的.dbx文件进行信息提取的,这些组件中的函数
默认就是与 Outlook 中的收件箱/发件箱/等,捆绑在一起的!

请问:如何利用现成的微软组件,如 IMimeBody 中的函数,来对真实的 .eml 文件进行解析处理,如提取附件的文件名,提取 subject (需要考虑多语言的解码显示)?
 


http://www.codeproject.com/com/Outlook_Express_Messages.asp
http://www.codeproject.com/internet/mimesniffer.asp
 


如何设置WINDOWS的环境变量(VC/MFC 基础类)


WINDOWS系统的环境变量中,我想设置其中的一项PATH,请问如何设置
我调用过SetEnvironmentVariable,_putenv,可是它好象只对本进程有效果,而我想永久改变这个环境变量
在WIN 2K和XP中,我最后是通过修改注册表的方法修改环境变量的,但是在WIN98中不知道如何解决


可以修改autoexec.bat文件里的路径

http://www.codeproject.com/tools/SetEnv.asp


如何去除CDialogBar窗口上的关闭按钮 (VC/MFC 界面 )


如何去掉浮动工具条中的“关闭”按钮
http://www.vckbase.com/document/viewdoc/?id=533

这个方法同样对CDialogBar有效

http://www.codeproject.com/docking/disabletoolbarclose.asp

 
原创粉丝点击