"SHSetKnownFolderPath" API doesn't work as expected on Windows 10 - winapi

I am using "SHSetKnownFolderPath" win32 API to change users "Desktop"(c:\users\administrator\Desktop) folder location programatically to D:\Desktop. Folder location changes as expected to D:\Desktop. There is a "Location" tab shown on this folder which tells where the folder currently resides. But "Location" tab should be shown only on D:\Desktop folder as its current desktop folder but the "Location" tab is shown on both folders (c:\users\administrator\Desktop) and (D:\Desktop).
Following is code I am using to change folder location
if(S_OK == SHSetKnownFolderPath( FOLDERID_Desktop, 0, NULL, L"D:\\Desktop"))
return TRUE;
The above problem is only on "Windows 10", on Windows 7 "Location" tab is shown only on (D:\Desktop) folder. I tried changing the Desktop location using "Location" tab which is shown when you right click and go to properties. Folder location changed to (D:\Desktop) and also the Location tab was shown only on (D:\Desktop).
What am I doing wrong and how can I fix it?

Related

Image cannot be loaded - Javafx

I`m trying to load image with code:
Image image = new Image(AddOrderController.class.getResourceAsStream("/resources/icons/ok_icon.png"));
And I receive exception:
java.lang.NullPointerException: Input stream must not be null
The tree of my project is simple:
When I'm adding ok_icon.png to package controller everything is ok and icon works, but in resources/icons the icon can't be loaded. Can anyone help me how to remake the code?
Since you have src/test/resources as a source folder, the contents of resources will be deployed as part of the application, to the root of the classpath. That means that icons is in the root of the classpath.
You can verify this by checking the contents of the output folder, which I'm guessing is target/classes, using the system file browser (Finder on a Mac, or Windows explorer, or whatever it is called these days). You can verify the output folder in Eclipse by choosing "Project" from the menu, then "Properties", select "Java Build Path", select the "Source" tab, and see what is specified as the "Default output folder".
If the path you supply to getResourceAsStream begins with a leading /, then the path will be interpreted relative to the classpath. So
Image image = new Image(AddOrderController.class.getResourceAsStream("/icons/ok_icon.png"));
should work.
Looks like you have to go one directory up first:
Image image = new Image(AddOrderController.class.getResourceAsStream("../resources/icons/ok_icon.png"));
if that doesn't work neither, check if the two source folders (src) are really the same or if they have a different parent folder

URL file under windows 10 shows wrong icon

I've made the next URL file using text editor:
[InternetShortcut]
URL=http://192.168.33.7/
IconFile=http://192.168.33.7/SomeICOFile.ico
HotKey=0
IconIndex=0
IDList=
and saved it on the desktop.
under windows XP The shortcut icon is the file saved on the server - SomeICOFile.ico
under windows 7 and 10 it gets the default browser icon as icon. (Yet, it leads to the right page).
I had the same problem. It seems that the name of the .url file must be same like the name of the .ico file in Win10

What is the path of "my computer" folder on windows?

I am working on a C++ windowsform project, using visual Studio IDE.
I use CFileDialog class to ask the user to select a file to open.
It display an usual open file selection windows.
I would like the default folder displayed to be the same as the one accessed when clicked on "My computer", where the harddrives, USB drives, dvd drives etc. are displayed.
I can define default folder by writting its path tolpstrInitialDir member, but I don't find the path for such a folder. I tried "\", "explorer.exe", "", none of them gave me the expected result.
The application will be used by several users, so the solution must not include the user name in the path. i.e "C:\Documents and Settings[user]\Desktop\My Computer" may work but is not correct for my application.
Does anyone know of to define the "root" path of windows (i.e the root of C:\) ?
I searched on SO and internet but maybe I have used wrong keywords because I couldn't find appropriate content.
My Computer is a virtual shell folder that doesn't correspond to any file system directory. There's no file system path that would correspond to that location.
Fortunately, file dialogs do speak "shellese", so you can use the CLSID (not to be confused with the GUID KNOWNFOLDERID or the CSIDL) of the shell folder. Sample in C# Winforms, but really, the only important part is the ::CLSID):
var ofd = new OpenFileDialog();
ofd.InitialDirectory = "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}";
ofd.ShowDialog();
Disclaimer: I couldn't find any relevant documentation for the virtual folder CLSID, or this behaviour of the File dialog. So this is most likely not contractual, and could possibly change in future versions of Windows.
In the explorer, in the search bar copy the address of
This PC
and then select the text
This PC
and paste. Normally we get the
Ce PC ":: {CLSID}"
and then just copy
:: {CLSID}
and paste it wherever we want.
Path should be: C:\Users\UserName\Desktop\Computer.lnk

how to set default location for uploading files or selecting files in window 8

hello every and thanks in advance.
how i can set the default location for the choosing file dialog box and uploading file dialog box to a single directory in window 8.
i want to search in c:/somefolder every time when i chose or upload file from any where however it not happen if i select from desktop then next time it also makes the desktop as the default location.
i think window 8 chose the recent location as default location but i don't want that and i want to restrict to same folder even if i upload file from desktop or any where else.
You can try this:
FileOpenPicker folderPicker = new FileOpenPicker();
folderPicker.ViewMode = PickerViewMode.Thumbnail;
folderPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
you can get the list of locations in PickerLocationId from here

How to customize a folder programatically on Windows 7

Windows 7 offers the possibility to customize folder icons and pictures by right clicking on the folder, choosing the "Properties" command and then the "Customize" tab, as explained for example here.
Can this be done programatically ?
Yes, you can create a desktop.ini file programmatically. The file is documented here.
You could, for instance, rename the folder in an internationalization scenario (e.g. a folder named "users" could me displayed to the user as utilisateurs on a French OS, or Benutzer on a German OS), by creating a file with the following contents:
[.ShellClassInfo]
LocalizedResourceName=#C:\foo\bar.dll,-100
which would take the name of the folder in the bar.dll string resource ID 100.

Resources