Difference between MFC program. \ and API function GetModuleFileName

Source: Internet
Author: User

First, ". \" and the system API function GetModuleFileName are used to obtain the address of the current program running.

The difference is that ". \" indicates the relative path, while GetModuleFileName gets the absolute path for running the program.

When the program runs in Windows, there is basically no difference. However, if the program runs under Wince, since Wince does not support relative paths, all paths can only be obtained by calling the system API function.

Usage:

". \" Is followed by the relative address of the file or the file name.

The GetModuleFileName usage is as follows:

CString CIniFileOpe: GetSystemPath ()
{
TCHAR MyexeFullPath [MAX_PATH];
CString MyAppPath;

GetModuleFileName (NULL, MyexeFullPath, MAX_PATH );
CString strPathTemp;
StrPathTemp = MyexeFullPath;
Int iLastPos =-1;
Int iStartPos = 0;
Do
{
IStartPos = iLastPos;
ILastPos = strPathTemp. Find (_ T ("\"), iStartPos + 1 );
} While (iLastPos! =-1 );
MyAppPath = strPathTemp. Left (iStartPos + 1 );

Return MyAppPath;

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.