CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2008
    Posts
    2

    Problem with Japanese system

    Hi,
    I am facing trouble in a Japanese systems.

    I am trying to create a shortcut/file on to user desktop. Its failing with out any clue.

    I am creating a short cut in "C:\\Documents and Settings\\username\\デスクトップ\\link.lnk"

    Where デスクトップ is the string "Desktop" equivalent in Japanese. I am storing the path using wchar_t data type. The problem I feel is that we are not able to access the デスクトップ folder. I am getting an error telling that the file name, directory name, or volume label syntax is incorrect. All the Windows API call using this path is failing. I am able to create files and shortcuts in C:\\Documents and Settings\\username" but not inside C:\\Documents and Settings\\username\\デスクトップ" folder. The API is working fine it has got something to do with the data representation.


    Normal file creation is also failing. The code extract is

    wchar_t name[MAX_PATH];
    mbstowcs( name, "C:\\Documents and Settings\\username\\デスクトップ\\link.lnk", MAX_PATH);
    CreateFileW( name, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );

    What am I missing out. Thanks for your help and suggestions..

  2. #2
    Join Date
    Nov 2003
    Posts
    1,902

    Re: Problem with Japanese system

    It's not a good idea to put characters outside the "basic" character set in your source code. You can read more about that here: http://www.codeguru.com/forum/showpo...8&postcount=14.

    Why not use SHGetFolderPathW(), or the like, with CSIDL_DESKTOPDIRECTORY?

    gg
    Last edited by Codeplug; December 10th, 2008 at 06:00 PM.

  3. #3
    Join Date
    Dec 2008
    Posts
    2

    Re: Problem with Japanese system

    Yes I am using SHGetSpecialFolderLocation only. I am using the following code to get the desktop directory

    LPITEMIDLIST itemList;
    HRESULT hres;
    hres = SHGetSpecialFolderLocation(NULL, CSIDL_DESKTOPDIRECTORY, &itemList);

    if(hres != S_OK)
    {
    return hres;
    }

    char desktopDir[MAX_PATH];
    if(!SHGetPathFromIDList(itemList, desktopDir))
    {
    }

    aftre this I am using desktopDir and converiutng it in to wchar_t. It is working perfectly in Windows English system. Its giving problem only in Japanese system.

  4. #4
    Join Date
    Nov 2003
    Posts
    1,902

    Re: Problem with Japanese system

    Don't use any char strings. Just use wide API's.
    And use code tags when posting code.
    Code:
        ITEMIDLIST_ABSOLUTE *itemList;
        HRESULT hres;
        hres = SHGetSpecialFolderLocation(NULL, CSIDL_DESKTOPDIRECTORY, &itemList);
        if (hres != S_OK)
            return hres;
    
        wchar_t desktopDir[MAX_PATH];
        BOOL bHaveDir = SHGetPathFromIDListW(itemList, desktopDir);
        CoTaskMemFree(itemList);
        if (!bHaveDir)
        {
        }
    gg

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured