I need to format a pen drive from within a C# application.
I've googled around and the only thing I can find is http://msdn.microsoft.com/en-us/library/aa394515(VS.85).aspx
But I need it to work on Win XP, so that solution won't do for me.
Can anyone suggest an alternate method?
You could try to simply fork (not the linux fork :) ) a new process and run the Windows format command from inside your C# program.
Related
I would like to create an R-Package as R interface for a C# program.
At the moment it works quite well by just using the shell or system function on windows.
shell("C:/path/to/executable.exe")
This is clearly not satisfying as an .exe file is not working on Linux or MAC.
As I have the possibility to include the C# source code into my package and theoretically compile it while installing it on any OS, I was wondering if and how I can achieve that.
The rClr package seems to be an option but I am having trouble to understand how to actually use it for my purpose.
So my first question is:
Is it possible to do what I am trying to do or is it simply not possible and should I discard my wish to make the package usable on all OS?
If so it would save me a lot of time and I can do something else.
My second question would than be: If it is possible, how can I do it and where do I start?
I have a problem with different sound libraries...
I use Visual Studio.NET and C#
I have programmed a small simulator with ebedded sound and want to have a audio library which also has pause and volume control. So I tried SDL.NET and IrrKlang. Both are working, but I want to have the simulator as a "standalone" simulator so I have to embed the audio libraries to the simulator. I tried the testversion of smartassembly, but the SDL.NET library isn't fully integrated and with Irrklang, smartassembly said that there is nonmanaged code in the irrklang library and it aborts.
So I have multiple questions:
-Is there a simple audiolibrary which I can embed easily?
-Is there a, for example, .cs-file of an audio library so I don't have to embed a .dll?
-Can I change a .dll so I have mangaged code?
Thx
EDIT:
Errormessages with SmartAssembly:
SDL.NET:
Tao.NET.dll and SDLdotNET.dll can be embedded, but SDL.NET (The Core) is not a valid .COM-Library so it can't be embedded
IrrKlang:
-IrrLang.dll can be embedded, but after converting the program says that there is "non-managed" code in library so it can't be embedded.
What can I do??
Try nAudio: http://naudio.codeplex.com/, you will have full source code.
But that's a library like others.
Or maybe try to edit your question and add error messages you get
Ok, got it finally to work :)
I used the irrklang.dll but I had chosen the "Depencies Merging"-Option in {smartassembly} instead of the "Depencies EMBEDDING"-Option
Now it works perfectly :)
Thx Pierre that you wanted to help me :)
Wonderwhy
How can I automatically run my C# program after hard-reset or soft-reset on Windows CE?
in your applications .reg file, add the following:
[HKEY_LOCAL_MACHINE\init]
"Launch50"="PlatformStartup.exe"
"Depend50"=hex:14,00,1E,00
Source - http://msdn.microsoft.com/en-us/library/aa446914.aspx
Hope that helps!
[HKEY_LOCAL_MACHINE\init] will not launch your C# app! You should read that article Chris Tacke gave link to.
There is also some ready solutions like AutoLaunch, that you can include in your OS image as a subproject. If you choose this solution, make sure that you have the APIs it is waiting for (check IsNetworkReady()) or it will hang there forever.
I have an .INF for a virtual printer that I need to install from a .NET Application. I have done this before using batch scripts, but I am looking for a snippet of code to do this in the .NET Framework.
There's nothing particular about the printer .INF, so any code that installs a printer from an INF in C# or VB.NET will work.
I believe this is possible via interop to native win32 APIs, but I've found its much, much easier just to use a System.Diagnostics.Process() to call into printui.dll via:
rundll32.exe printui.dll,PrintUIEntry /?
Perhaps you're already using that in the mentioned batch script, but if not the parameters are documented here: PrintUI.DLL User's Guide and Reference
Just be sure to test it against all operation systems you need to support. Some options either do not exist in all Windows releases or have been renamed (although I think they're the more esoteric options - installing an .INF will likely work across the board).
You are going to want to look at the WMI objects available. These give you a finer control of the local machine settings. Take a look at the WMI code creator from Microsoft, I believe this will generate some example code you can leverage to solve your problem.
Administering Printer Settings in C# for Flexible Printing
see this article, it uses an MS Platform SDK DLL called PRNADMIN to manage printers, printer-drivers, printer-ports, ...etc.
I personally use it in a commercial project to install a printer driver and change the printer port to local port to intercept the Postscript. and it works like a Charm.
Alternatively you can use some pre-installed vbscripts that come with windows in C:\Windows\system32\Printing_Admin_Scripts and here is a an articles for them:
http://technet.microsoft.com/en-us/library/cc771846.aspx
This is not the ideal solution, but if nobody else answers, you can create a temp batch file and invoke that through C#/VB.NET.
Someone else will probably know a more natural way to do this.
You will need to wrap the setup APIs using PINVOKE or a native COM object.
Does anybody have a known reliable way to create a video from a series of image files? Before you mod me down for not searching for the answer before posting the question, and before you fire off a simple message like "use FFMPEG," read the rest of this message.
I'm trying to create a video, it doesn't matter too much what format as long as it's widely supported, from a series of images (.jpg, .bmp, etc.). My platform is Windows Server 2008, 64-bit. If I can make the video from within my C# program, that's great, but I'm not averse to writing a series of image files to a directory and then firing off an external program to make a video from those images.
The only constraints are: it must work on my Windows Server 2008 system, and be scriptable. That is, no GUI programs that require operator intervention.
I found a number of similar questions on StackOverflow, and have tried several of the solutions, all with varying degrees of frustration and none with anything like success.
FFMPEG looks like a great program. Maybe it is, on Linux. The two Windows builds I downloaded are broken. Given this command line:
ffmpeg -r 1 -f image2 -i jpeg\*.jpg video.avi
One of the builds reads the images and then crashes due to data execution prevention. The other reads the first file and then spits out an error message that says "cannot find suitable codec for file jpeg/image2.jpg". Helpful, that. In any case, FFMPEG looks like a non-starter under Windows.
One answer to a previous posting recommended Splicer . It looks like pretty good code. I compiled the samples and tried to run, but got some cryptic error message about a file not found. It looks like a COM class isn't registered. I suppose I need to install something (DirectShow, maybe, although I thought that was already installed?). Depending on what's required, I might have a difficult time justifying its installation on a server. ("What? Why do you need that on a server?")
Another answer suggested the AviFile library from Code Project. That looks simple enough: a wrapper around the Windows AviFile subsystem. Except that the AVI files the package creates appear to have all of the frames, but only the first frame shows when I play the AVI in Windows Media Player. Well, that and if you try to create a compressed video, the program throws an exception.
So, I'm left wondering if there is a good, reliable way to do what I want: on a Windows system, create an AVI or other common video file format from a series of images, either through a .NET API or using an external program. Any help?
After working with it a while and taking a look at x264 and VideoLan, I went back to Splicer. It turns out that the cryptic error message was due to an error in my code.
It looks like Splicer will do what I want: programmatically create videos from a series of images.
Thanks to all who responded.
You can use VideoLan and I'd recommend it.
I've had direct experience in a C# application with VideoLan doing these two things:
Embedding a VLC viewer in my C# application (there are 3-4 C# "wrappers" for the VLC veiwer).
Using vlc.exe in a separate Process by sending it command-line arguments.
The fact that VideoLan has a command-line interface is a great thing. And VLC supports a command-line option that disables any visual element; so the VLC GUI doesn't pop up and neither does a command-line window. Thus, in a C# application you can farm out the video-related work to the VLC client. C# has the Process class which can manage your vlc.exe instances for you. It ends up being a pretty neat solution.
The handling of video on Windows (encoding and playback) is a real quagmire. And .NET isn't going to help you at all - you're always going to be either PInvoking/COM-interoping native APIs or using a .NET wrapper that someone else has built to do the same.
Anyway, I can't say I've used it, but a good bet seems to be the x264 library that is part of the videolan project. That gives you a self-contained C library that you can PInvoke and you don't have to worry about installing and DirectShow garbage on your server. It'll generate H.264 format video which is playable in Flash as I understand it.
I've used mplayer's mencoder to create AVI (with codecs msmpeg4/mp3, readable by default with Windows Media Player) from TGA files on linux like this:
mencoder mf://*.tga -mf fps=25:type=tga \
-audiofile /tmp/test.mp3 -oac copy \
-of lavf -ovc lavc \
-lavcopts vcodec=msmpeg4v2:mbd=2:mv0:trell:cbp:last_pred=3:vbitrate=3000 \
-o /tmp/test.avi
I know mplayer does have a Windows version.
Instead of just going through all the hassle, you could coppy all the images that you want to be included in your video to the clipboard and have it imported into Windows Live Movie Maker (dynamically, of course!) and have it compile for you!
All of this CAN be done through code, but this way, you don't have to create it yourself. As you said that the platform was Windows, and ALL Windows comps have Windows Live Movie Maker installed, so it shouldn't be a problem for anyone using your application unless
a) They uninstalled Windows Live Movie Maker
b) They are using a computer running on a Windows Version more than 8 or 9 years old...