LoginSignup
0
0

More than 5 years have passed since last update.

C++ Builder > CSIDL_BITBUCKETでごみ箱のパスを取得できない (文字化け) | ごみ箱: special group of objects

Last updated at Posted at 2017-10-17
動作環境
C++ Builder XE4

CSIDL @ MSDN

Unit2.cpp
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit2.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm2 *Form2;
//---------------------------------------------------------------------------
__fastcall TForm2::TForm2(TComponent* Owner)
    : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm2::B_checkRecycleBinClick(TObject *Sender)
{
    //LPTSTR getPath[255];
    wchar_t appdata[255];
    SHGetSpecialFolderPath(NULL, appdata, CSIDL_APPDATA, false);
    OutputDebugString(appdata);

    wchar_t recycle[255];
    SHGetSpecialFolderPath(NULL, recycle, CSIDL_BITBUCKET, false);
    OutputDebugString(recycle);
}
//---------------------------------------------------------------------------
デバッグ出力: C:\Users\XXX\AppData\Roaming プロセス Project1.exe (1852)
デバッグ出力: [化けた文字] プロセス Project1.exe (1852)

質問中: https://stackoverflow.com/questions/46781659/getting-recycle-bin-folder-with-csidl-bitbucket-resulting-in-garbled-strings

(追記 2017/10/18)
ゴミ箱のPItemIDListは取得できるが、実際のパスは取得できない、というようなコメントが付いた。自分が検索して読んだ情報でも似たような情報で、実際に試した結果もそのようであった。

ごみ箱: special group of objects

http://computer-programming-forum.com/82-mfc/eb60eae5f2e5ac99.htm

Mark Henr #8/9
あたりを見ていると、ごみ箱は特殊なグループに属するようだ。
それを読むには色々しないといけないようだ。

固定文字列実装

Unit3.cpp
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit3.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm3 *Form3;
//---------------------------------------------------------------------------
__fastcall TForm3::TForm3(TComponent* Owner)
    : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm3::Button1Click(TObject *Sender)
{
    String recycleBin = L"C:\\$Recycle.Bin";

    ShellExecute(NULL, NULL, L"explorer.exe", recycleBin.c_str(), NULL, SW_SHOWNORMAL);
}
//--

上記の実装で以下の環境でゴミ箱が開いた。

  • Windows 7 pro (32bit)
  • Windows 8.1 pro (64bit)
  • Windows 10 pro (64bit)

固定文字列だと将来のOSに対応できない可能性がある。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0