Tuesday, September 23, 2008

How to know which DLLs are being used by a program in Windows?

From the command line run the following command syntax:

tasklist /m /fi "IMAGENAME eq [filename.exe]"

Replace the [filename.exe] above with the executable file name for which you need information.

For example: With Notepad.exe

Command:
tasklist /m /fi "IMAGENAME eq notepad.exe"

Sample Output:

Image Name                   PID Modules
========================= ====== =============================================
NOTEPAD.EXE                 3340 ntdll.dll, kernel32.dll, comdlg32.dll,
                                 ADVAPI32.dll, RPCRT4.dll, Secur32.dll,
                                 COMCTL32.dll, msvcrt.dll, GDI32.dll,
                                 USER32.dll, SHLWAPI.dll, SHELL32.dll,
                                 WINSPOOL.DRV, ShimEng.dll, AcGenral.DLL,
                                 WINMM.dll, ole32.dll, OLEAUT32.dll,
                                 MSACM32.dll, VERSION.dll, USERENV.dll,
                                 UxTheme.dll, IMM32.DLL, LPK.DLL, USP10.dll,
                                 MSCTF.dll, msctfime.ime, autoaway.dll

Update: 2023-07-20
Here is a screenshot from Windows 11


Note: To open the Command Prompt, go to Start > Run. Then type CMD and hit Enter.


Wednesday, September 10, 2008

Large Hadron Collider Activated

The Large Hadron Collider (LHC) was activated for the first time today on 10 September 2008. The LHC is the world's largest and most powerful subatomic particle accelerator.

Tuesday, September 2, 2008

Google Chrome (Beta) Released

Google has launched the beta release of an open source web browser named Google Chrome which is available for Windows XP and Vista only. The browser can be downloaded from here for free.

Google Chrome is based on WebKit, the open-source rendering engine which is used by Apple’s Safari browser and Google’s Android operating system.

The web browser market is presently dominated by Microsoft's Internet Explorer with 80% of the market.

Google also launched a 38-page comic book along with the browser to describe its usage which is available here. The Blogoscoped article here covers details of what is going on. BBC has covered the event here.







Thursday, July 24, 2008

CStatic control loses transparency in Visual C++

I want to display some information on a control with transparent background. I am using a CStatic control and when opening, the control has a transparent background. But when I try to set the desired information in the control, my control loses transparency and it becomes like a basic CStatic control although it has been set to be transparent. I have overridden the OnPaint method from the derived CStatic class named StaticCtrl. Here is the code of the OnPaint method. I don't do anything else. I only override OnPaint.

void StaticCtrl::OnPaint()
{
    CPaintDC dc(this); // device context for painting
   
    // Where to draw text
    CRect clientRect;
    GetClientRect(clientRect);
   
    // Get the caption
    CString strTitle;
    GetWindowText(strTitle);
   
    // Get the font
    CFont *pFont, *pOldFont;
    pFont = GetFont();
    pOldFont = dc.SelectObject(pFont);
   
    DWORD dwStyle = GetStyle(), dwText = 0;
   
    // Map "Static Styles" to "Text Styles"
    #define MAP_STYLE(src, dest)
        if(dwStyle & (src)) dwText |= (dest)
    #define NMAP_STYLE(src, dest)
        if(!(dwStyle & (src))) dwText |= (dest)
   
    MAP_STYLE(SS_RIGHT, DT_RIGHT);
    MAP_STYLE(SS_CENTER, DT_CENTER);
    MAP_STYLE(SS_CENTERIMAGE, DT_VCENTER | DT_SINGLELINE);
    MAP_STYLE(SS_NOPREFIX, DT_NOPREFIX);
    MAP_STYLE(SS_WORDELLIPSIS, DT_WORD_ELLIPSIS);
    MAP_STYLE(SS_ENDELLIPSIS, DT_END_ELLIPSIS);
    MAP_STYLE(SS_PATHELLIPSIS, DT_PATH_ELLIPSIS);
    NMAP_STYLE(SS_LEFTNOWORDWRAP | SS_CENTERIMAGE |
               SS_WORDELLIPSIS | SS_ENDELLIPSIS |
               SS_PATHELLIPSIS, DT_WORDBREAK );
   
    // Set transparent background
    dc.SetBkMode(TRANSPARENT);
   
    // Draw the text
    if(GetDlgCtrlID() == IDC_STATIC_CANCEL)
    dc.SetTextColor(RGB(255, 0, 0));
   
    if(GetDlgCtrlID() == IDC_CONNECTIONTXT ||
       GetDlgCtrlID() == IDC_RATETXT)
    dc.SetTextColor(RGB(250, 100, 0));
   
    if(GetDlgCtrlID() == IDC_PERCENT ||
       GetDlgCtrlID() == IDC_REMAINING ||
       GetDlgCtrlID() == IDC_TIMETXT)
       dc.SetTextColor(RGB(250, 100, 0));

    dc.DrawText(strTitle, clientRect, dwText);
   
    // Select old font
    dc.SelectObject(pOldFont);
}

Solution: If you have changed the CDialog background color, you will notice that CStatic & some other controls' background colors still show as the system default COLOR_BTNFACE color. To handle this issue, just make the controls' background transparent so it takes up the color of the dialog's background. Use something like this in your subclassed CDialog's OnCtlColor() event handler to make the background of all static text controls on the dialog transparent. This code considers CMyDialog was derived from CDialog.:

HBRUSH CMyDialog::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
    HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
    CBrush m_brHollow = m_brHollow.CreateStockObject(HOLLOW_BRUSH);

    if (nCtlColor == CTLCOLOR_EDIT) {
        pDC->SetTextColor(RGB(0, 0, 0));  // text color
        pDC->SetBkMode(TRANSPARENT);      // background mode
        hbr = m_brHollow;                 // return NULL brush
    }
   
    return hbr;
}

If you have painted your dialog background with WHITE, CMyDialog::OnCtlColor() I posted above works fine with CStatic controls on the dialog. But if you have a CSliderCtrl control on the dialog, you'll see that the code above makes the background color of the CSliderCtrl control pitch BLACK.

A work-around is simply to return a handle to a WHITE brush instead of a NULL brush like the code below. This code snippet considers CMyDialog was derived from CDialog & the dialog background was painted white by overriding the CDialog::OnEraseBkgnd() method.

HBRUSH CMyDialog::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
    HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
    CBrush m_brBgColor;

    // dialog background WHITE
    m_brBgColor.CreateSolidBrush(RGB(255, 255, 255));
   
    if (nCtlColor == CTLCOLOR_EDIT) {
        pDC->SetTextColor(RGB(0, 0, 0)); // text color
        pDC->SetBkMode(TRANSPARENT);     // background mode
        hbr = m_brBgColor;               // return WHITE brush
    }
   
    return hbr;
}

Refer this.



Friday, August 17, 2007

WikiScanner can track anonymous Wikipedia edits

WikiScanner or Wikipedia Scanner provides an online searchable tool that takes a database dump from Wikipedia and crawls through anonymous edits which were made from source IP addresses that can be traced back to organizations who may have a vested interest in the content of the respective Wikipedia pages. It uses a IP2Location database to connect IP addresses with organizations.

In most cases these were edits where the organizations would have removed content with criticism. The homepage lists the following organizations as editor's picks on its homepage.

  1. Government
    1. U.S. Senate Sergeant At Arms
    2. U.S. House Of Representatives
    3. Environmental Protection Agency
    4. National Institute of Health
    5. Democratic Party
    6. Republican Party
    7. NATO
  2. Education
    1. California Institute of Technology
    2. Bob Jones University
  3. Policy
    1. Electronic Frontier Foundation
    2. The Rand Corporation
    3. National Rifle Association
    4. American Civil Liberties Union
  4. Corporate
    1. Diebold Inc
    2. Amgen Inc
    3. Pfizer Inc
    4. Wal-Mart Stores Inc
    5. ExxonMobil
    6. Raytheon
  5. News
    1. Washington Post
    2. Washington Times
    3. Fox News Channel
    4. New York Times Company
    5. Al-Jazeera
  6. Locations
    1. Ft. George G Meade, Maryland
    2. Havana, Ciudad De La Habana
  7. Misc
    1. darpa.mil
    2. Central Intelligence Agency
    3. Church of Scientology
    4. Vatican
    5. Christian Science Publishing Society
    6. Church of Latter Day Saints

The creator, Virgil Griffith, wrote in the FAQ page that he created WikiScanner "to create a fireworks display of public relations disasters in which everyone brings their own fireworks, and enjoys". He however suggests that a tool like WikiScanner is not necessary and anonymous speech should be preserved.

The Wired wrote See Who's Editing Wikipedia - Diebold, the CIA, a Campaign to break the story. 

The online tool is available here.

Compact disc hits 25th birthday

The world's first compact disc (CD) was produced by Philips and Sony 25 years ago, revolutionizing the music industry and becoming a dominant format. CDs have sold over 200 billion units worldwide and are still popular despite digital downloads' growth. The CD's development involved overcoming technical challenges, and it was initially aimed at holding an hour of audio but extended to 74 minutes for a complete symphony. Although CD sales have declined in recent years, they remain a significant format, cherished by some music enthusiasts. Here is an article from BBC News on the compact disc turning 25.

Monday, August 13, 2007

Google Shutting Down Google Video

Google is shutting down its premium video service, leaving users who purchased or rented content unable to access their videos in the future. They won't receive refunds but are offered a $5 credit on Google Checkout, expiring in 60 days. The move comes after Google's acquisition of YouTube on October 9, 2006, making Google Video less relevant. Analysts criticize the decision, as users lose access to content they bought despite functioning players. Google originally launched this video hosting service on January 25, 2005. The BBC reports it here.