How do I use FileOpenDialog and Image in WinPE using C#, WPF - c#

I'm developing an application to run on WinPE.
I use C# and WPF(.Net Framework 4.5)
But I face some problems.
I would like to use select file using FileOpenDialog. it is not operated in WinPE(version 6.3)
I tried two way to use FileOpenDialog
System.Windows.Forms.FileOpenDialog - Not happed anything
Microsoft.Win32.FileOpenDialog - Exception Occurred
Another problem is a Image.
I want to use image but some images will not be appeared.
The image has small size under 1KB appear normally. But the image has large size over 400KB do not appear on the screen.
All functions are normally operated on Windows 10 But these problems only appear in WinPE.
How do I solve these problems?

to get the fileDialog running, you need to copy ExplorerFrame.dll from a running windows 10 system. The file is located in system32 folder. keep an eye on the architecture.
You need to add the following registry modification to your WinPE-registry, too. This helped me out with the same issue several months ago. Depending on your app, you'll need to install WinPE-WMI.cab, WinPE-PowerShell.cab, WinPE-NetFx.cab and their language-packs as well. These can be found in MS ADK.
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SW\Classes\CLSID\{AE054212-3535-4430-83ED-D501AA6680E6}]
#="Shell Name Space ListView"
[HKEY_LOCAL_MACHINE\SW\Classes\CLSID\{AE054212-3535-4430-83ED-D501AA6680E6}\InProcServer32]
#=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,65,00,78,00,\
70,00,6c,00,6f,00,72,00,65,00,72,00,66,00,72,00,61,00,6d,00,65,00,2e,00,64,\
00,6c,00,6c,00,00,00
"ThreadingModel"="Apartment"

Related

How does Windows Photo Viewer get the files for the slideshow from Windows Explorer?

I wrote an image viewer application in C# to replace Windows 7 Photo Viewer which does not have the one feature I needed, which was to set the ratings and keywords directly from the view screen and not by opening some less user-friendly property pages. It works Ok for my need, but I wanted to improve it with a slideshow.
With Windows 7 Photo Viewer, what I usually did was I set the keywords of the picture, I used Windows Explorer "organize by" feature, clicked one keyword, double-clicked one file and run the slideshow from there.
But when I double-click a file from the keyword-"organized" folder in Windows Explorer, all my app gets is the command-line argument, i.e. the full name of the file.
I could admit running my slideshow from there, using System.IO.Path.GetDirectoryName to get all files from the folder, but I find it lacks a certain "panache", don't you think?
I am not asking for code here. But could someone just point me in the right direction, please? I don't know what WindowsExplorer actually gives PhotoViewer that allows it to only show the required files. And why.
Thanks for any help.
When you use Organize by feature of Windows Explorer it creates special virtual folder. And this folder contains files with selected keyword only. Mechanism of opening of PhotoViewer differs from standard way. If you open HKEY_CLASSES_ROOT\jpegfile\shell\open registry key you will see that where is DropTarget subkey. It means when you double-clicked the file shell creates inproc com server with CLSID from DropTarget subkey and pass virtual path of image to IDropTarget instance. So PhotoViewer work with list of virtual objects instead of physical directory.

Some of the images are not coming after Publishing WPF application

I have published my WPF application using ClickOnce publishing method. I ran the application on the client PC and I noticed that some of my images are not appearing e.g. Background images of Windows. I looked carefully and found out that one Sample.jpg Photo is properly showing inside the Image container which I've used for every record.
Same goes for another image n still coming. The problem I am not able to figure out why both these two images are coming and not the background one?
While creating the Application I have put all the images in a single Folder and all images are referenced from this single folder only.
I also tried by simply copying my project>BIN folder files to client machine and yes, all images are loaded properly without any issues. The problem is only coming in the publish version of my application.
Could anyone help me in this? are there any settings I should take care of while deploying the application? Or I should move them to any specific location?
Are your images Build Action property set to content and the Copy to Output directory property set to Copy always/Copy if newer?

Windows Form Application : Publish issue

I'm very new to Visual Studio 2010. I decided to create a simple WFA with C#.
Everything work fine with Images and Audio playback. My intention is to create a standalone application and send it to my friend as a gift. Problem I facing now is that when I tried to publish the application, the Images / Audio is still using the same location in my PC. So it won't play nor display any images.
Any comment on this or guide for me? I did try search for solution but doesn't seems to have any luck.
This is the code that I used to play Audio :
SoundPlayer ply = new SoundPlayer(#"C:\Users\Liam619\Documents\Visual Studio 2010\Projects\BirthdayApp\BirthdayApp\Resources\BirthdaySong.wav");
If I remove or change the path, the Application will hit error for locating the Audio file.
There may be several solutions to your problem.
a) embed the sound into a resource. As a beginner, resources may be a bit tricky to get it right the first time. But I want to encourage you reading something about it. You'll need resources when you want to translate your first program.
b) create an installer which copies the sound file to the installation directory. Try InnoSetup. If you're a programmer, sooner or later, you'll need to create a Setup anyway. Always worth knowing how to do that.
In that case, you still need the path to the sound file, but if you install your EXE into the same path as the sound file, see getting the application's executable directory.
everything in the database whether images or audio refers to your own server database.you have to send the database too with the app and the correct version .NET framework needs to be installed on the target PC.

Location of Windows Phone 8 files that are marked as content

I'm creating Windows Phone 8 Direct3D application with XAML (C++).
I have to process several files in my C++ code before I can use them. These files are added to the Component project and marked as content.
After I processed them, I want to use them from my XAML C# application.
What path should I use to access these files?
It seems that
ApplicationData.Current.LocalFolder
doesn't contain any of them.
Or what conception should I use in my application to solve the problem?
Those items will be in Windows.ApplicationModel.Package.Current.InstalledLocation but you should copy files to ApplicationData.Current.LocalFolder on first launch.

C#: How would you organize a screen saver in the file system?

I am planning to create a screen saver. Thinking of trying out some WPF as well. Anyways, I am not quite sure how I would organize the screen saver on disk in the file system. I have mainly two related issues that I am very uncertain on how to solve:
Normally an application lives, with all its 3rd party assemblies, static resources, images, etc., in the Program Files folder and is run from there. For example C:\Program Files\MyScreenSaver. But (if I haven't missed something) the executable of a screen saver in windows need to have the scr extension and to live in the system folder, for example C:\Windows\System32. How do you program the screen saver so that it can find the "rest of itself"? Would you use the windows registry? Or creat some sort of config file next to the scr file with the path to the rest? And would you make the scr to just be sort of a launcher of an exe in the application folder? Or would this be a bad idea?
I also want the screen saver to download new content from certain places on the internet. But where do I put it, and how does the screen saver find it? If I have understood correctly, an application is not to create new contents in its application folder, but rather in a user folder. How do I find that folder? Do you build it up from environment variables? And in what specific directory should things like this really be in? For example on Vista I see that you have one folder called C:\ProgramData. You also have C:\Users\username\AppData\Local, C:\Users\username\AppData\LocalLow and C:\Users\username\AppData\Roaming. Have also seen a lot of programs dump stuff in the my documents folder (although I hate programs cluttering up my documents folder, so I will probably try to avoid that :p).
What are some best practices when it comes to these issues of laying out your application in the file system? I am want it to be best and "most correct" for Windows 7, which means it will probably work the same in Vista as well (?), but it would also need to work in XP, since a lot of people are using that still.
I'm still using XP :)
System.Environment.SpecialFolders is what you want for these special locations.
Say,
System.Environment.SpecialFolder.LocalApplicationData
For a screen saver I'd try to put most of it in the .exe (.scr) file. It might make the executable quite big but I think it's worth it.
For the downloaded content use application data folder, or maybe allow user to set the location (put the path in registry). For example if you are downloading images, the user might want to put that in My Pictures folder.
You can put it in the System32 (or SysWOW64) folder, but you can also put it in just the Windows folder, which would prevent x86 vs x64 issues.
You can find some other hard to find, but important information about writing screen savers here:
https://github.com/steveniles/MandelZoom/wiki
(Disclosure: I wrote the above wiki as a companion for the source code of one of my own screen savers.)

Categories