Files
Open-Shell-Menu/ClassicStartSrc/ClassicStartLib/FileHelper.cpp
Xenhat 0adcd693e4 Some branding and licensing work (#22)
* Fix stdafx include

* Fix basic handling of "Games" folder on Windows10 RS4 (#10)
This does the following:
- Sets the default state to hidden
- Skips the Games folder when searching

This does not:
- Hide the dead menu entry.

I do not currently know how to actively change the user preference setting to forcefully hide it.

* Add basic Visual Studio gitignore

* Add specific entries to gitignore

* Do not set default menu to Win7 on RS4 (#10)

* Rename "PC Settings" to "Settings" (#12)

* Create distinction between modern and legacy settings in search results

* Add more build artifacts to gitignore

* Add default paths for toolset and build all languages

* Fix several memsize, memtype and nullpointer issues

* create trunk branch containing all changes

* set fallback and next version to 4.3.2, set resource fallback value to allow loading in IDE

* add generated en-US.dll to gitignore

* Don't echo script contents, add disabled "git clean -dfx" to build fresh

* Initial re-branding work (#21)

* Create copy of __MakeFinal to build all languages (Use this file when releasing new versions)

* Move the registry key IvoSoft->Passionate-Coder (#21)

* Change company/mfg name IvoSoft->Passionate-Coder (#21)

* Update some leftover copyright dates (#21)

* Fix accidental copy-paste breaking MakeFinal scripts

* Fix invalid company name for Wix and change registry keys to match the new string (#21)

* Update more copyright and legal text (#21)

* Update RTF files format (Wordpad generated those) (#21)

* update license text in RTF files (#21)
We lost the blue link text in the installer page. Will have to manually re-color all the links later.
2018-06-25 01:42:52 -04:00

63 lines
1.9 KiB
C++

#include "stdafx.h"
#include "StringUtils.h"
bool CreateFakeFolder( const wchar_t *source, const wchar_t *fname )
{
// create directory
CreateDirectory(fname,NULL);
if (!SetFileAttributes(fname,FILE_ATTRIBUTE_READONLY))
return false;
// create shortcut
wchar_t path[_MAX_PATH];
Sprintf(path,_countof(path),L"%s\\target.lnk",fname);
{
CComPtr<IShellLink> pLink;
HRESULT hr=pLink.CoCreateInstance(CLSID_ShellLink);
if (FAILED(hr)) return false;
pLink->SetPath(source);
CComQIPtr<IPersistFile> pFile=pLink;
if (!pFile) return false;
hr=pFile->Save(path,TRUE);
if (FAILED(hr)) return false;
}
// create desktop.ini
Sprintf(path,_countof(path),L"%s\\desktop.ini",fname);
HANDLE f=CreateFile(path,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM,NULL);
if (f==INVALID_HANDLE_VALUE) return false;
const char *desktopIni="[.ShellClassInfo]\r\nCLSID2={0AFACED1-E828-11D1-9187-B532F1E9575D}\r\nFlags=2\r\n";
DWORD q;
WriteFile(f,desktopIni,Strlen(desktopIni),&q,NULL);
CloseHandle(f);
return true;
}
void DeleteFakeFolder( const wchar_t *fname )
{
wchar_t path[_MAX_PATH];
Sprintf(path,_countof(path),L"%s\\target.lnk",fname);
BOOL res;
res=SetFileAttributes(path,GetFileAttributes(path)&~FILE_ATTRIBUTE_READONLY);
res=DeleteFile(path);
Sprintf(path,_countof(path),L"%s\\desktop.ini",fname);
res=SetFileAttributes(path,GetFileAttributes(path)&~FILE_ATTRIBUTE_READONLY);
res=DeleteFile(path);
res=SetFileAttributes(fname,GetFileAttributes(fname)&~FILE_ATTRIBUTE_READONLY);
res=RemoveDirectory(fname);
}
bool IsFakeFolder( const wchar_t *fname )
{
wchar_t path[_MAX_PATH];
Sprintf(path,_countof(path),L"%s\\target.lnk",fname);
if (GetFileAttributes(path)!=INVALID_FILE_ATTRIBUTES)
{
Sprintf(path,_countof(path),L"%s\\desktop.ini",fname);
DWORD attrib=GetFileAttributes(path);
if (attrib!=INVALID_FILE_ATTRIBUTES && (attrib&FILE_ATTRIBUTE_SYSTEM))
return true;
}
return false;
}