????? ????? ??????? Windows XP ???? ???? ?????? ?????? ??????? ????????? ?? ?????? ?????? ???????? Visual c + +

?????? ????????? ?????? ?????????
???? ???????: 310294 - ??? ???????? ???? ????? ????? ??? ???????.
??? ????? ??? ??????? ??? ??????? ??? ????? ????? ???????. ???? ?? ??? ???? ???????? ?? ????? ??? ??????. ???? ?? ??? ???? ????? ???????? ?? ???? ???? ?????. ????? ?? ????????? ??? ????? ????? ????? ????????? ???????? ?????? ?????? ???? ??? ??? ??????? ?????? ?????? ?? "????? ??????? ? Microsoft":
322756 ????? ??? ???? ???????? ?? ????? ????????? ?? ???? ??????? Windows
?????? ???? Microsoft Visual c + +.NET 2002? Microsoft Visual c + +.NET 2003 ? Microsoft Visual c + + 2005 ? Microsoft Visual c + + 2008 ?? ?? ???? ????????? ???????? ??????? ???? ?? ??????? ?? ??? Microsoft.NET Framework ???? ??????? ????? ????????? ???????? ??????? ?? Microsoft Windows. ????? ????????? ??????? ?? ??? ??????? ??? ??? ????????? ???????? ??? ??????? Visual c + +
????? ???? | ?? ????

?? ??? ??????

??????

????????? ???? ?????? ?? ????? ?? ???????: ??? ???? ???? ???????? ?????? ???? ???? ???? ??????? ??????. ????????? ?????? ?? ??? ??????? ?????? shell SHGetFolderPath ???????? ????? ???? ???? ?????? ???????? ??? ???? ????????? ????????. ???? ????? ????? ??????? Windows ??????? ???? ??????? XP ???? ?????? ?? ?????????? ????? ???????? ??? ???? ????????? ? ?????? ?????????? ?? ??????? ?????.

???? ??? ??????? ????? ????? ?????? ???????? ?? ?????? ?????? ?? ??????? ???????:
  • ????? ????? Win32.
  • ????? ??? ???? ??????? ???????.
  • ??????? ????? ??? ??? ???? ?????? ??? ????????? ??? ?????? ??????.
  • ?????? ?? ??? ????? ???? ?????.
  • ???? ??????? ?????? ????? ?????????.
  • ???? ?? ????? ???????? ???????.
?? ??????? ???????? ??? ???? ???? ?? ??? ????? ?????? ??????? ?????? ?????? ?? ?? ??? ?????? ?? ??????? ????????:
  • ????? ?????? ???????.
  • ????? ?????? ??????? ?? ?????? ??????.
  • ??????? ??????? ????.

???????

???? ??????? ??????? ??????? ?????? ???? ???????? ???? ?????? ??????? ????????? ????????? ????? ??? ???? ???????:
  • ???? ??????? Windows XP Home Edition ?? Windows XP Professional
  • Visual Studio 2008 Visual 2005 ????? ?? Visual Studio.NET.
  • ??????? ??????? ?????? ??????? Win32

????? ????? Win32

??? ????? Visual Studio? ?????? ????? Win32 ???? ???? ??????????.
  • ?? Visual Studio.NET, ???? ??? Visual c + + ???????? ??? ????? ????????? ?? ???? ???????? Win32 ??? ?????. ???? ??????? ??????? ????????? ????? ????? ??????? ????.
  • ?? Visual Studio 2005 ?? 2008? ???? ??? Visual c + +??? ????? ????????? ?? ???? ??? Win32 ??????? ??? ?????. ???? ????????? ??????? ???????.

????? ??? ????? ??? ??????? ???

  1. ???? ??? ??? ???????? ?? ???? ????? ??????? ??? IDC_SAVINGDATA.
  2. ????? ??? ???? ???? ???????? ???????. ??????? IDM_FILE_SAVEAS ?????? ???? ???????.
  3. ????? ???? ??????? ???? WndProc ??????? ???? SavingData.cppm ?????? ???? ?????? ???? ???? ??? ????? WM_COMMAND ??????? ??? ???? ???? ???????. ???????? ???? ???????????? ? ???? ????? ???????? ?? ?????? ??????. ??? ???? ???? ??? ??????.

    ??? ?? ???? ????????? ???????? ?????? ?? ??? ???:
    case WM_COMMAND:
        wmId    = LOWORD(wParam);
        wmEvent = HIWORD(wParam);
        // Parse the menu selections:
        switch (wmId)
        {
        case IDM_ABOUT:
            DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
            break;
        case IDM_EXIT:
            DestroyWindow(hWnd);
            break;
        case IDM_FILE_SAVEAS:
            OnFileSaveAs(hWnd);
            break;
        default:
            return DefWindowProc(hWnd, message, wParam, lParam);
        }
        break;
    

?????? ???????? "??? ???" ???? ?????? ???? ??????? ??? ?????? ??????

????? ???? ?????? ???? ??????? ??? ???(?? ??? ???) ???? ???? ????? ??????? ???? ?????? ??? ????? ????????? ??? ???? "?????????" ????? ????????? (?? ???? ?????? ?? ?????????? ??? ????? ??????? ????? ????????? ????? ?????).

??????: ????? ??? ??? ??? ????? ?????? ???? ???? ??????? ????? ?? ??? ?? ???? ???? ????? ??????. ??? ???? ??????? ????? ?? ??? ???? ????????? ??? ???? ??? ????.
  1. ?? ????? ?????? ?? SavingData.cpp? ????? ??????? ??????? ??????:
    #include <commdlg.h>   // for GetSaveFileName
    #include <shlobj.h>    // for SHGetFolderPath
    					
  2. ????? ??????? ?????? ??????? ?????? ???????????? :
    void OnFileSaveAs( HWND hWnd );
    					
  3. ????? ???? OnFileSaveAs ???????. ???? ??? ??????? ?????? ?????? SHGetFolderPath ????????? ?? ???? ?????CSIDL_MYPICTURES ???????? ???? ?????? ?????? ?????? ?????? ??????. ????? ???? ??? ?????? ??? ???? ??????????????? ???? ??????? ??? ??????? ??????.

    ??? ?? ???? ????????? ???????? ?????? ?? ??? ???:
    void OnFileSaveAs(HWND hWnd)
    {
       OPENFILENAME openFile;
       TCHAR szPath[MAX_PATH];
       TCHAR szFile[MAX_PATH];
    
        // Initialize OPENFILENAME structure.
        ZeroMemory( &openFile, sizeof(OPENFILENAME) );
        openFile.lStructSize = sizeof(OPENFILENAME);
    
        szFile[0] = '\0';
        openFile.hwndOwner = hWnd;
        openFile.lpstrFile = szFile;
        openFile.nMaxFile = sizeof(szFile)/sizeof(*szFile);
    
        // Default to My Pictures. First, get its path.
        if ( SUCCEEDED( SHGetFolderPath( NULL, CSIDL_MYPICTURES, 
                                              NULL, 0, szPath ) ) )
        {
           // Set lpstrInitialDir to the path that SHGetFolderPath obtains. 
           // This causes GetSaveFileName to point to the My Pictures folder.
              openFile.lpstrInitialDir = szPath;
        }
        // Display the standard File Save dialog box, defaulting to My Pictures.
        if ( GetSaveFileName( &openFile ) == TRUE )
        {
            // User clicks the Save button.
            // Save the file
        }
        else
        {
           // User cancels the File Save dialog box.
        }
    }
    

?????? ?? ??? ????? ???? ?????

  1. ???? ??????? F5 ????? ???????.
  2. ????? ???????? ?? ???? ??? ??? ?????? ??? ???????.
  3. ???? ?? ?? ??????? ??? ??? ?????? ???? ????????? ???? My pictures? ??? ???? CSIDL_MYPICTURES .
  4. ???? ??? "????? ?????" ?????? ???? ??????? ? ?? ?????? ???????.

???? ??????? ?????? ????? ?????????

???????? ???? ??? ??? (?? ??? ???) ???? ??????? ??? ???????? ?? ???? ?????? ????????? ???????? ?????? ?????? ????.

??? ?? ??? ????? ???? ???? ???? ??? ???? OPENFILENAME ? ??????????????? (? GetOpenFileName) ????? ??????? ??? ??? ?? ??? ??? ???? ?????? ???? ???? ??? ???? "?????????". ???????? ??? ???? ??? ??? ???????? ?? ?????? ???? ?? ?????? ?????? ??? ?????? ???? ??????? ???? ??? ???????? ??? ??????? ?????????? ???????? ?????? ??????? ??????.

???? ???? ????????? ????????? ???????? ???? ???? ???? (??? ?????) ????? ?????? ???? ???? ?????? ???? ?? ???? ?????? ?????? ???? ??? ????????? ???????? ???????? ????? ????? ??? ???? ??????? ????? Boolean ????? ?? ??? ???? ??? ?? ??? ????? ???????? ????? ??? ?? ????? ?????.
  1. ????? ????? BOOL ???? ???? ?????????? ?? ?????? ???????????? ??????? ??? TRUE.
  2. ????? ????????? ???????? ???? ???????????? ???????? ????????????? ?????? ????? ??????????????? ???? OPENFILENAME ? ??? ?? ???? ?????????????? .
  3. ???????? ?????? ??? ??? ????? ??? ???? ??????? ?????? ?????????? ??????.

    ??? ?? ???? ????????? ???????? ?????? ?? ??? ???:
    void OnFileSaveAs(HWND hWnd)
    {
        OPENFILENAME openFile;
        TCHAR szPath[MAX_PATH];
        TCHAR szFile[MAX_PATH];
        static BOOL bFirstSave = TRUE;
    
        // Initialize OPENFILENAME structure.
        ZeroMemory( &openFile, sizeof(OPENFILENAME) );
        openFile.lStructSize = sizeof(OPENFILENAME);
    
        szFile[0] = '\0';
        openFile.hwndOwner = hWnd;
        openFile.lpstrFile = szFile;
        openFile.nMaxFile = sizeof(szFile)/sizeof(*szFile);
    
        // The first time the user saves a document, default to My Pictures.
        if ( TRUE == bFirstSave )
        {
            if ( SUCCEEDED( SHGetFolderPath( NULL, CSIDL_MYPICTURES, 
                NULL, 0, szPath ) ) )
            {
                // Set lpstrInitialDir to the path that SHGetFolderPath obtains.
                // This causes GetSaveFileName to point to the My Pictures folder.
                openFile.lpstrInitialDir = szPath;
            }
        }
        // Display standard File Save dialog box, defaulting to My Pictures
        // or the user's previously selected location.
        if ( GetSaveFileName( &openFile ) == TRUE )
        {
            // User clicks Save.
            // Save the file.
            bFirstSave = FALSE;
        }
        else
        {
            // User cancels the File Save dialog box.
        }
    }
    

???? ?? ????? ???????? ??????

  1. ???? ???????? ?????? ???????.
  2. ?? ??? ???????? ???? ??? ??? ???.
  3. ????????? ?? ???? ????? ??? "???? ?????????" ??????? ??? ??? ?? ???? ??? ???.
  4. ?? ??? ???????? ???? ??? ??? ??? ??? ????.
  5. ???? ?? ?? ???? ?????? ????????? ??? ?????? ??????? (?? ??? ??????? "?????????").
  6. ???? ??? "????? ?????" ?????? ???? ??????? ??? ?????? ???????.
  7. ????? ???????? ?? ???? ??? ??? ?????? ??? ???????.
  8. ???? ?? ?? ???? ?????? ????????? ??? ???? ??? "???? ?????" ????.
  9. ????? ???? ??????? ?? ????? ???????.

????? ?????? ???????

?? ??? ????? ???????? ?????? ???????? (??? ??????? ????? ???????? ???????? ????? ????? ??????? ?????) ?? ?????? ?? ???? "?????????". ????? ?? ???? ?????? ????? ??????? ?? Windows ??????? (???????? ???? ?? ?????? 64 ???? ????) ?? ??????? ?????? ???????? ??????? ?? "?????? ???????" ???? ????.

?? ????? ?????? ?????? ??????? ?? ?????? ?????? ?????? ???? ????? ???????? ??? ???? ????????? ??? ????? ?? ??????? ??? ???????? ???????? ?? ?????.

?????? ???? ?????? ?????? ??????? ??????? ????? ??? ?????? ?????? ??????? ????? ???????? ?????? ??:
  • ??? ?????? (????????): ??? ??? ????? ?????? ??????? ?????? ?????? ???? ???? ?? ???? ???????? ??? ????? ???????? ??? ????? ????????? ??? ???? (??? ???? ??????? ????? ????). ?????? ?? ??? ?? ????? ??????? ??? ????????? ??? ??????? ??????? ?? ???? ????.
  • ??? ?????? (??? ????????): ??? ??? ????? ?????? ??????? ?????? ?????? ???? ??? ???? ??? ??? ???? ??????? ???? (??? ???? ??????? ??? ???? ?????? ??????? ?? ??? ????????).
  • ??? ??????? (??? ?????? ????? ???? ????????): ??? ??? ????? ?????? ??????? ???? ????? ??? ???? ?????????? ???? ??????? ???? (??? ???? ??????? ??? ????? ?????? ??? ???? ?? ??? ????).

????? ?????? ??????? ?? ?????? ??????

????? ??????? ?????? ????????????? ???????? ?????? "?????? ???????" ??????. ?? ??? ???? ????? ?????? ??????? ?????? ?? ??? ??????. ????? ?? ???? ?????? ?????? ???????? ?????? ???? ???? ?????? ???? ???? ?????? ????????????? . ???? ?? ??? ????? ??????? ???????? ??????:
??????? Name\Product Name\Product ??????
??? ???? ??????? ?? ???? ?????? ?????? ??????? ??? ???:
\Documents ?????????? ???? ?????????? ?????? ??????? Data\My Company\My Product\1.0
?????? ???? ?????? "?????? ???????" ??????? ????? ???? CSIDL ????????? ???????? ??? ??? ?????? ??????? ????? ??.
  • ??? ?????? ???????? (???????)? ?????? ?????? CSIDL_APPDATA . ????????? ?? ?????? ??????:
    \Documents and Settings\??? ????????> \Application ????????
  • ??? ?????? ???????? (????? ???? ????????)? ?????? ?????? CSIDL_LOCAL_APPDATA . ????????? ?? ?????? ??????:
    \Documents and Settings\??? ????????> ???????? \Local Settings\Application
  • ??? ?????? ????????? (??? ?????? ????? ?????? ???? ????????)? ?????? ?????? CSIDL_COMMON_APPDATA . ????????? ?? ?????? ??????:
    \Documents ?????????? ???? ?????????? ?????? ???????
??? ????????? ???????? ?????? ???? ????? ??? ??? ????? ??????? ???? ??? ???? CSIDL_COMMON_APPDATA:
include <shlwapi.h>
#pragma comment(lib,"shlwapi.lib")
void CreateTemporaryFile()
{
   TCHAR szPath[MAX_PATH];
   // Get path for each computer, non-user specific and non-roaming data.
   if ( SUCCEEDED( SHGetFolderPath( NULL, CSIDL_COMMON_APPDATA, 
                                    NULL, 0, szPath ) ) )
   {
      TCHAR szTempFileName[MAX_PATH];
      // Append product-specific path - this path needs to already exist
      // for GetTempFileName to succeed.
      PathAppend( szPath, _T("\\My Company\\My Product\\1.0\\") );
      // Generate a temporary file name within this folder.
      if (GetTempFileName( szPath, 
                           _T("PRE"),
                           0,
                           szTempFileName ) != 0 )
      {
         HANDLE hFile = NULL;
         // Open the file.
         if (( hFile = CreateFile( szTempFileName, 
                                   GENERIC_WRITE, 
                                   0, 
                                   NULL, 
                                   CREATE_ALWAYS, 
                                   FILE_ATTRIBUTE_NORMAL, 
                                   NULL )) != INVALID_HANDLE_VALUE )
         {
            // Write temporary data (code omitted).
            CloseHandle( hFile );
         }
      }
      else
          DWORD err = GetLastError();
   }
}

??????? ??????? ????

??? ??? ?????? ?? ????? ?? ???? ????? ??? ??????? ???? ???? ????? ????? ???????. ??? ???? ?? ???? ?????? ????? ??? ??? ?????? ????? ???? ??? ????. ????? ???? ?? ????? ??? ??????? ??????. ??????? ????????? ?? ???? ???? ???????? ?? ????? ??? ??????. ??? ???? ????? ??????? ????? ?? ???? ???? ?????. ????? ?? ????????? ??? ????? ??? ???? ???????? ?? ????? ?????????? ???? ??? ??? ??????? ?????? ?????? ?? "????? ??????? ? Microsoft":
322756 ????? ??? ???? ???????? ?? ????? ????????? ?? ???? ??????? Windows

????? ???? ??????? ??????? ?????? ????? ????? ?????? ???????. ???????? ???? ?????? 64 ???? ???? (KB)? ??? ???? ??????? ???? "?????? ???????". ?????? ????????? ??????? ??? ??????? ??????? ?????? ?????? ???????:
  • ?????? ??? ????? ????? ?? ?????? ????????? ?????? ????? ??????? HKEY_CURRENT_USER (HKCU).
  • ?????? ??? ????? ????? ?? ???????? ??? ?????????? ?????? ????? ??????? HKEY_LOCAL_MACHINE (HKLM). ??????? ????? ?? ??? ?? ???? ??? HKLM ?? ??? ??????? ?? ???? ???????? ?????????? ??? ????????? ??? ???? ???? ???? ??????? ??? ??? ???? HKLM .
  • ?? ??? ???????? ??????? ????? ?? ??? ??? ????? ???? ?? ?????? 128 ???? ???? ??? HKCU ? HKLM.
  • ??? ????? ?????? ???? ???? (COM) ???? ??? ????? ??????? HKEY_CLASSES_ROOT (HKCR). ?? ????? ???? ?????? 128 ???? ???? HKCR.
  • ??? ??????? ??? HKLM ?? HKCU, ??? ???? ????? ?????? ???? ??????? ??? ??????? ? ??? ????? ??????? ??? ???:
    ??????? Name\Product Name\Product HKLM\Software\Company
    ??????? Name\Product Name\Product HKCU\Software\Company
  • ?????? ???????? ??????? (??? RegCreateKeyEx??????????????) ?????? ?????? ??????? ???????.

??????? ??????? ????????

  • ???????? ?? ???? ?? ????????? ???? ??? ??????? ????? ?? ????? windows ???????? ??? ???? ??????? Windows XP? ????? ????? ????????????? ?? Shfolder.dll. ??? ????? ?? ??? ????? ???? ??????? Windows XP ????????????? ?? Shell32.dll? ?? ?? ???? ????????? ??????? ?? Windows ?????? ?? ????? ???????? ?????? (DLL).
  • Shfolder.dll ???? ??????? ?????? ??????? ????? ???? ??????? ?? ????????? ?????? ??.
  • ?? ??? ?????? ???????? ???? ???? ???? "???? ?????????" ?????? (?? ?????? ?????? ??????) ???? ??????? ???? ???? ??? ????? ??????? ????? ??????? ??????? ??? ???????? ?? ??????? ?? ??? ??? ???????? ??? ??????????? ????????? ??????? ????? ??.

?????

????? ???? ????? Visual c + +.NET ????? ??????? ? Microsoft ??????? ?? ?????? ???? ???.NET Visual c + + ?? Microsoft ??????? ???? ???:
???? ????? visual c + +.NET (2002)
http://support.microsoft.com/default.aspx?xmlid=fh%3BEN-US%3Bvcnet
????? ?? ????????? ??? ?????? ????? ?? ???????? ???? ???? ?????? ??? ????????????? ? ???? ????? Microsoft ??????? ??? ?????? ??????? ????? ????? Kit (SDK):
?????
http://msdn.microsoft.com/en-us/library/bb762494.aspx
?????? ??? ???? ?? ????????? ??? ????? shell ???? ???? ???? ???? ??? ???? ????? Microsoft (MSDN) ??????:
???? ????????? shell
http://msdn2.microsoft.com/en-us/library/bb776778.aspx

???????

???? ???????: 310294 - ????? ??? ??????: 12/?????/1434 - ??????: 4.0
????? ???
  • Microsoft Visual C++ 2008 Express Edition
  • Microsoft Visual C++ 2005 Express Edition
  • Microsoft Visual C++ .NET 2003 Standard Edition
  • Microsoft Visual C++ .NET 2002 Standard Edition
????? ??????: 
kbhowtomaster kbnewsgrouplink kbmt KB310294 KbMtar
????? ????
???: ??? ????? ??? ??????? ???????? ????? ?????????? ??????? ?????? ??? ??????? ?? ??? ??????? ?? ??????? ??? ??? ?? ???? ????????? ???? ??????? ???????(CTF) ?? ?? ???? ????? ????. ???? ?? ???? ?????????? ??? ???????? ???????? ???? ??? ?? ???????? ??????? ?? ??? ??????? ???????? ?? ??? ??????? ??????? ??? ?????? ?? ?????? ??? ???? ???????? ???????? ?? ????? ??????? ????? ????? ??????. ??? ?? ???????? ???????? ?? ????? ??? ????? ?? ???????? ?? ???? ????? ?? ?????. ?????? ??? ???? ?????????? ???? ?????? ?? ??? ????? ?? ??? ??? ?? ??????? ?? ??? ????? ?? ???? ????? ????? ?? ????? ??????? ???? ?? ???????? ?? ??? ???????.
???? ??? ????? ??????? ?????? ??????????310294

????? ???????

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com