2/05/2012

Where is the forum for Microsoft-related questions

There are many other forums that you can explore that might be right for your Microsoft-related question and here is my personal list of those. If you believe you found a Microsoft bug you can also discuss publicly it to get more votes when you submit to Microsoft's public bug database (update: discontinued, for Windows use the Feedback app) . More votes means the bug is higher on the todo list.

List of a few forums on Microsoft's site, including IT professional and software developer forums
http://forums.microsoft.com -- (update: discontinued)

For software consumer questions  

For designer questions related to the Microsoft Expression Studio

Windows Help and Support site with community supported newsgroups. Very helpful with Vista problems.
http://windowshelp.microsoft.com (update: discontinued, use Microsoft Answers instead)

There are several Microsoft products teams host community content on their own web site, such as ASP.Net, IIS, XNA/DirectX, Silverlight and Expression. For example:

ASP.NET has its own forums for web programmers which also covers Windows Web Developer Express edition.
http://forums.asp.net (update: discontinued, use Microsoft Q&A)

For web server administrators and IIS extension (ISAPI) developers, IIS also has its own forums.
http://forums.iis.net (update: discontinued, use Microsoft Q&A)

For multimedia, game and graphics application developers, the XNA and DirectX team (Including DirectDraw and DirectSound, but not DirectShow, which is now part of Windows SDK) is hosting their forum on xna.com.
http://forums.xna.com/  (update: discontinued, use Microsoft Q&A)

For IE users, there are Internet Explorer forums on answers.microsoft.com. For IE extension developers, and web developers who need to support IE, MSDN has forums for IE extension development and web development.  (update: discontinued, use Microsoft Q&A)

For Microsoft Office users and business application developers, Office forums can be found at http://support.microsoft.com/gp/gp_newsgroups_master. (C++ programmers may need a VBA to C++ translator)  (update: discontinued, use Microsoft Q&A)

Networking development communities, including higher layer libraries and services like Microsoft .Net base class library's networking classes , Peer to Peer (P2P) Networking, Quality of Service (QoS), as well as lower layer APIs like Winsock, Windows Filter Platform (WFP) networking, WinInet, etc. For some reason web related forums are also listed on this page, such as ASP.Net, Silverlight, IE and IIS forums.
http://msdn.microsoft.com/en-us/network/bb190188.aspx  (update: discontinued, use Microsoft Q&A)

For people who want to discuss ways to redistribute their software using Windows Installer and ClickOnce:

InstallSite contains Windows Installer information for developers. Desktop Engineer's Junk Drawer and AppDeploy.com is for IT professionals who need to deploy application to multiple computers in a cooperation. For ClickOnce, Visual Studio's Setup & Deployment Projects and Windows Form control deployment for IE, the official forum is athttp://social.msdn.microsoft.com/forums/en-US/winformssetup/threads/  (update: discontinued, use Microsoft Q&A)


Choosing a forum in MSDN forums for software development questions  (update: discontinued, use Microsoft Q&A)

For language questions such as syntax or compiler for a language, ask in language forums such as Visual Basic Language,Visual C# Language and Visual C++ Language. Language forums are not for everything can expressed in a the language. That's why other forums exist in the first place.


For IDE questions like how to use Visual C++ or C#'s Wizards or how to change IDE settings, ask in IDE forums such as Visual C# IDE or Visual Basic IDE. Note Visual Studio shared features may have their own forums, like forums under the Visual Studio,Visual Studio Express and Visual Studio Team System categories. There are forums not under these categories too, such as the Windows Form Designer forum under the Windows Form category.

For questions regarding class libraries like the MFC, ATL, .Net framework classes under the System or Microsoft namespaces, ask in library forums like forums.asp.net, msdn forums under the .Net development (System.IO belongs to the Base class library forum), Windows Forms and Data Platform Development categories. 

Some products such as Visual C++, Visual J# and Visual Foxpro may not have their own Language/IDE/Librariy forums on MSDN right now. They will have general forums for questions for Language/IDE/Library questions instead.

There are other forums that cover other issues that you may experience during programming. For example if you get a security exception when trying to open a file using the System.IO.File class, you may want to post in the Common Language Runtime forum if you think it is related to .Net's security settings, or the Security for Applications in Microsoft Windows forum under the Software Development for Windows Client category if the cause is NTFS/Active Directory permission settings.

Of cause this is not a complete list of Microsoft forums. So do a search to see where questions similair to yours get frequently answered (not just frequently posted).

What is the Windows API for...


There are the questions programmers ask frequently. This faq does not contain sample code,  readers should use keywords (showing in bold, such as function names, CLSIDs or interface names) to find complete solutions elsewhere.

Q: What is the Windows API for the Start Menu?

A: The Windows API for locating the start menu is SHGetFolderPath. Alternatively, you can also use SHGetSpecialFolderPath or SHGetSpecialFolderLocation with SHGetPathFromIDList. New applications, that is, application only targeting Windows Vista and do not intend to support Windows XP, should use SHGetKnownFolderPath. Oh, before I forget, .Net programmers can use System.Environment.GetFolderPath. Some newer APIs do not support locating start menu location of all users, though.

You can use the IShellLink interface to create or modify a link in the start menu folders. To use the IShellLink interfaces, you need to create a COM object with the CLSID CLSID_IShellLink (in computer's perspective, that is 00021401-0000-0000-C000-000000000046).

Q: What is the Windows API for the Task Bar?

A: Use ITaskbarList2 (for Windows XP and above) or ITaskbarList (for Windows 2000 and lower) to control the tabs. In Windows 2000 and lower, to hide the task bar when your full screen application is running, you need to useSetForegroundWindow and SetWindowPos to cover the entire screen, while on later systems you can use ITaskbarList2::MarkFullscreenWindow.

To use ITaskbarList/ITaskbarList2 interfaces, you need to create a COM object with the CLSID CLSID_TaskbarList (in computer's perspective, that is 56FDF344-FD6D-11d0-958A-006097C9A090), query interface for ITaskbarList/ITaskbarList2, and use the HrInit method to initialize the object.

Q: What is the Windows API for the System Tray?
A: You can use the Shell_NotifyIcon function to add, modify, or delete icons from the status area. Sometimes, the desktop process (explorer.exe) is killed, and later recreated. However, custom icons does not reappear in the system tray automatically. Your should handle a registered message TaskbarCreated to reinstate your icon to the status area. In .Net, the System.Windows.Forms.NotifyIcon Class handle the icon recreation nicely.

Q: What is the Windows API for the quick launch bar?
A: There is no real difference between the quick launch bar and the start menu, except for the folder identifier. You can use the same set of APIs to locate the folder of the quick launch bar and and modify its content.

Q: What is the Windows API for shutting down or log off the Windows?
A: The API to shutdown or logoff the computer is ExitWindowsEx. The user identity of the calling process should have the SE_SHUTDOWN_NAME privilege (computer recognize it as SeShutdownPrivilege). The calling process must use theAdjustTokenPrivileges function to enable the privilege to the process..Net programmers, you are not suppose to do this kind of thing, but if you are determined to do so, use pinvoke to call this function.

Q: What is the Windows API for running an program?
A: If you are using C++, use system() for portablity. if you want to communicate with the new process, such as waiting for the process to end, sending message to the process or redirecting standard input/output of the new process, use CreateProcess. Otherwise use ShellExecuteEx, it is easier to set up. Oh, no, don't use WinExec. It does not let you to control the working directory. That may cause problems for some programs. .Net programmers can useSystem.Diagnostics.Process.Start method, which in turn call CreateProcess or ShellExecute.

Q: What is the Windows API for the automating Outlook Express?
A: The Windows Mail (formally Outlook Express) API does not provide a Document Object Model for automation. There are undocumented methods to hook or subclass the outlook windows, though. If you are writing Outlook Express extensions, take a look at the source code of PGP's Microsoft Outlook Express plug-in. With email softwaer completely removed, these API no longer apply to Windows 7.

Integrating Windows Desktop Search in Visual C++


This is a revised version of an earlier blog at http://blog.joycode.com/jiangsheng/archives/2005/07/19/59725.joy,  published July 19, 2005. The source code is available here:
.


The beta version of Windows Desktop Search (WDS) is released for a while. The SDK with a sample in C# is available for download at http://addins.msn.com/devguide.aspx. And using it in Visual C applications is quite easy, too.



First, you need to import ADO, since WDS uses ADO to return search results

#import "c:\Program Files\Common Files\system\ado\Msado15.dll" rename("EOF","adoEOF") rename("DataTypeEnum","adoDataTypeEnum")
using namespace ADODB;

Then import the wdsQuery.tlb file, which can be found in the SDK
#import "wdsQuery.tlb" rename("EOF","adoEOF") rename("DataTypeEnum","adoDataTypeEnum")
using namespace WDSQuery;

You need a CLSID to create the search engine object. The CLSID of the WDS object is not too hard to find in the wdsQuery.idl, which is also part of the WDS SDK.

DEFINE_GUID(CLSID_SearchDesktop,0x1AD68C99,0x00FB,0x416d,0x80,0x4B,0xC3,0x8D,0xEE,0x75,0xD5,0x5E);

Now you can create the object like this

ISearchDesktopPtr m_pSearchDesktop;

if(m_pSearchDesktop.CreateInstance(CLSID_SearchDesktop))
{
    AfxMessageBox(IDS_FAILED_TO_CREATE_SEARCH_ENGINE);
    return FALSE;
}

The object has two search methods that return an ADO recordset. The ExecuteSQLQuery method is the friendly one, takes a string and return the search result. The ExecuteSQLQuery method, on the contrary, accept a SQL statement. Believe me, you won't eager to construct the SQL by yourself. The parameter list of the ExecuteSQLQuery method is long enough. Here are the columns I choose:

DocTitle,DocFormat,Url,DocAuthor,PrimaryDate,FileName, FileExt,IsAttachment,Characterization,Rank,PerceivedType, HasAttach,DocTitlePrefix,FileExtDesc,DisplayFolder, DocKeywords,DocComments,ConversationID,Size, Create,Write
void CWDSSampleView::Search(LPCTSTR lpszQuery,LPCTSTR lpszSort)
{
 CString strQuery(lpszQuery);if(strQuery.IsEmpty())return;
 CString strSort(lpszSort);
 USES_CONVERSION;
 HRESULT hr=S_OK;
 GetListCtrl().SetItemCount(0);
 ClearCache();
 try{
  CString strColumns;
  VERIFY(strColumns.LoadString(IDS_COLUMNS_GENERAL));
  if(strSort.IsEmpty())
   m_pRecordset=m_pSearchDesktop->ExecuteQuery(T2OLE(strQuery),
    T2OLE(strColumns),NULL,NULL);
  else
   m_pRecordset=m_pSearchDesktop->ExecuteQuery(T2OLE(strQuery),
    T2OLE(strColumns),T2OLE(strSort),NULL);
  int nItemCount=m_pRecordset->GetRecordCount();
  GetListCtrl().SetItemCount(nItemCount);
  
 }
 catch(_com_error&e)
 {
  ……
 }
}

See, to increase performance, I used a cache and a virtual list control. But the application is still a little slow, if the search result list is too large. A better way to return the result set is to reduce date transfer. The search should only return the primary key column and the sorting columns, and when an item is about to be displayed, search again to get the information of this item.

How To Determine When a Page Is Done Printing in WebBrowser Control


SUMMARY
The printing from a WebBrowser control can be customized by using custom headers and footers ( http://support.microsoft.com/kb/267240) or replacing the default print template. However, using such techniques conflicts with the PRINT_WAITFORCOMPLETION flag, which is used for synchronous printing.

Since Internet Explorer 6.0, the WebBrowser control raises the DWebBrowserEvents2::PrintTemplateTeardown event when a print template has been destroyed. If the printing involves a custom print template, this is a good indicator of print completion. You can create a event handler function in your application for this event to determin if a the WebBrowser control is finished printing a Web page.
MORE INFORMATION

The WebBrowser control launches another thread which hosts another MSHTML document which renders to the printer. When this thread is finished, if a custom print template is involved, the WebBrowser control destroys the print template and raises PrintTemplateTeardown event. This indicates that the WebBrowser control has completed printing the Web page.

If the default print template and the customization of headers and footers are desired, load the template from the source of IExplorer.exe, and use it as a custom template.

To translate the asynchronous printing to synchronous, a message loop need to be created (better if use with a timeout handler) .

BOOL PrintTemplateTeardownFired=FALSE;
//launch printing......
//loop until PrintTemplateTeardown is set to TRUE in the PrintTemplateTeardown event handler
MSG msg;
while (!PrintTemplateTeardownFired&&GetMessage(&msg, NULL, 0, 0) > 0)
{
  TranslateMessage(&msg);
  DispatchMessage(&msg);
}

Reference

About Me



Hi, my name is Sheng Jiang. Most of you know me because I am active in several C++ forums and newsgroups, and publishes technical articles namely MSDN forums, Joycode (http://blog.joycode.com), a Chinese blog site focused on Microsoft technology, and CSDN, the largest Chinese-speaking software programming community in the world.


According to CSDN, I have around 20,000 posts on its forums (http://community.csdn.net), about 1/300 of the total posts. I am the forum moderator of the Visual C++ and .Net forums in CSDN, and the forum moderator of Chinese forums on Microsoft's MSDN forums, where I have around 15,000 posts and a top 10 contributor. I sometimes also take part in discussions in several other technologies, such VB, C#, Java and assembly language, as well as other online forums, including StackOverflow, GotSpeech.Net and Codeproject message boards, but at a lot less frequency. I have around 200 posts per year on StackOverflow, QQ Ask and Microsoft public newsgroups.

I also wrote blogs and publish dozens of articles per year. Frequently updated blogs include the blog.joycode.com/jiangsheng and blog.csdn.net/jiangsheng. I also posted a few articles in CodeProject before. My interested topics include MFC, ATL, C++/CLI, Web developing, Windows Shell, Windows Forms, Windows common controls, Windows Media, Desktop Search, Windows Speech, IE programming, security, C++ tips and Visual Studio tricks.

You can contact me via http://twitter.com/jiangsheng or webbo.com/jiangshengvc

Education
B.S. in Math, Jilin University, Changchun, China
Austin Community College

Employment
InfraHealth
Beijing Flex Sunland Centry
Beijing Encyc Digital
Beijing Sunland Centry

Awards
Microsoft Most Valuable Professional 2004-2012
First class prize of Jilin Province in China Undergraduate Mathematical Contest in Modeling, 1997