I have no idea if it is possible to calculate urban electric power Hz frequency, on PC without any external electric or electronic device.
I want to get electric power Hz through Os, power supply, motherboard or any other data source available in a normal PC, best practical code for me is C#.
Usually, in many countries, electric current is 50 or 60 Hz. Now I want to calculate it in my code, on my computer, without any external device, and best case is that code be so harmless to run on remote server, internet server without need for any special permission. In CMOS, BIOS and windows registry there are many hidden data, may be one usefull for this.
Any help is welcomed.
EDIT No, don't miss understand, I don't need to know countries current Hz, I want to know Hz of power that my Pc is using, Here
(local place) power Hz and at the present time
This looks promising:
http://wutils.com/wmi/root/cimv2/power/ms_409/win32_powersupply/
This is WMI, and should be doable through C# assuming it actually works and gives you what you need
http://wutils.com/wmi/root/cimv2/power/ms_409/properties/range1inputfrequencyhigh.html
Dim wmiObject
Set wmiObject = GetObject( _
"WINMGMTS:\\.\ROOT\CIMV2\power\ms_409:" + _
"Win32_PowerSupply.CreationClassName=""Value"",DeviceID=""Value"",SystemCreationClassName=""Value"",SystemName=""Value""")
Wscript.Echo wmiObject.Range1InputFrequencyHigh
It looks like you may be able to use the sound card and microphone to detect the mains power supply frequency
see the section on System frequency-response analysis
http://www.techmind.org/audio/
Unless you have a very special equipment, the power supply doesn't tell anything to the Motherboard (and so to the OS). It's perhaps possible to query the Motherboard about the DC current it receives, but it would be useless for what you are trying to do.
As always, if no one has done it before you, there are two possibilities: you are a genius or it can't be done. Normally sadly it is the second one :-)
Related
I want to make a program and sell it, so I was thinking to make some kind of licensing system. What I've found on google is this:
http://www.codeproject.com/Articles/28678/Generating-Unique-Key-Finger-Print-for-a-Computer
I am running Windows 7 (32 bit) in VirtualBox from Ubuntu. I get the same UID, but when I restart my Windows, I get a new UID. I am just thinking that some people will buy my program and they may run it from VirtualBox, so it would be a problem.
Do you guys have any suggestions?
Even if it's an easier way, but something that won't change even if I restart my VBox.
You need to not get so bogged down in the whole DRM process, there are always smarter people out there and someone will work out how to circumvent it.
If you're really concerned:
Set up an online license server to hold your users licenses
Prevent the application from doing anything until the user enters a valid license
This licence would be validated over the internet by your service
You could restrict the number of "active" applications using your service that way
Think along the lines of how iTunes allows you to authorise up to 5 computers to access your media library.
Even if a lot of time has passed, I want to add a possible solution to this question, pointing out something that happened to me trying to generate a fingerprint with exactly that code and facing the same problem.
The identifier function retrieves only the first not-empty value of wmiProperty for each wmiClass. The first important thing you should be aware of is this: what is returned for every wmiClass might not belong to the same ManagementObject. Hence, if something changes to "not the first object", this might affect also your fingerprint.
Be advised that using Win32_DiskDrive as wmiClass is dangerous since plugging in a USB device often results in this device being recognized as the first one (instead of your hard drive), changing the fingerprint as you plug-in or out your device. Even if this doesn't happen, still one of the wmiProperty could be taken from your USB device if your main drive has it empty (e.g. the disk signature, which happened to me).
A possible solution to that would be excluding all USB devices by checking InterfaceType and excluding all those who match "USB", or at least that's what I did.
Is there any script/software/algorithm which allows to convert a MIDI (or WAV) file to a list of <frequency, duration> so that we can replay an 'image' of this sound file, for example, through the System.Console.Beep(frequency, duration) function in C#?
You need to convert the MIDI, WAV or other sound file to raw audio samples. Then for successive blocks of samples (typically overlapping each block by 50%), apply a window function (e.g. Hanning), then an FFT, then take the magnitude of the FFT output bins, then for audio you would usually take 20*log10 of this magnitude to get a dB value.
For MIDI, you must either parse the file yourself (which I have done, and I recommend the following two references: one and two), or get a MIDI toolkit. I don't know of any for .NET but here is a Google search.
Once you get that, it should be fairly easy. Read in the MIDI file using the toolkit, and this will give you a set of tracks. Each track contains a sequence of events, each with a timestamp relative to the previous event. An event can be "note on", "note off", or one of hundreds of other events you probably don't care about and can ignore for this exercise. Just look for the "note on" and "note off" events. Usually, each note is a "note on" (with a certain pitch and velocity, which is volume) followed by a "note off" some time later (with the same pitch, and a velocity of 0).
So armed with this information, you can construct a table of notes with a quadruple (start time, duration, pitch, velocity), where start time is the time of the "note on" event, duration is the time difference between "note on" and "note off", and pitch/velocity is the pitch/velocity of the "note on". You can convert the pitch to frequency using this formula.
As for WAV/MP3/AAC/OGG, all of those have the same technique which is what Paul suggests in his answer.
Paul R's explanation is fine for WAV.
For MIDI, you're going to have to pick a track and read in the MIDI data. How you decide which track is up to you, but you can really only pick one, since you only get one "note" at a time out of the PC speaker, using your method.
C# MIDI Tutorial: http://www.codeproject.com/KB/audio-video/MIDIToolkit.aspx
Once you have read up on that, you should know how to read a MIDI file in. From there, you can translate that to frequencies and durations. The duration depends on tempo and the number of ticks that a note lasts, and the pitch will depend on a note number and its corresponding frequency according to equal temperament. (If you wanted to get really crazy, you could even handle alternate tunings, but I wouldn't worry about it for now.)
Also, I believe NAudio has some MIDI classes for reading files, but they may not be complete.
While we're getting crazy... if you could thread it effectively (this would be near impossible I'd imagine, but...), for WAV playback, you could use PWM to drive the PC speaker and emulate PCM audio playback. I remember some old DOS games from Necrobones used to do this, and there was a driver for Windows 3.1 that worked great on my 33MHz laptop for the usual clicks and dings. Although this method from a managed framework (or even within Windows without a realtime priority) might be very difficult.
So, I have this desktop app built using WPF and C#. It's basically an offline course system that has videos, quizzes, and other assorted content. My dilemma is that I don't know how to protect the videos once they are downloaded and installed on the users machine? Are there any DRM systems out there that I can look into? I thought about storing them in a local encrypted database but I don't even know where to start with that (or if there is something else out there that I'm totally missing...)
Don't even know where to start looking on this one - any ideas?
this question might be helpful, but don't spend too much time on it as any DRM is likely to be broken (they spent millions trying to protect blu-rays and couldn't). At best you can deter the casual user, but you won't prevent the determined hacker, so don't waste time trying.
you could do something trivial to make sure that the files as is can't be copied and played as is (like swap a few bytes round in the header of the file to make it seem as if its garbage so won't be played, then unswap them in memory when you read the file - just an example, I'm no expert)
I've seen Bink video used in some games. I believe it has some sort of built-in "scrambling system", but I might be wrong.
How to uniquely identify computer (mainboard) using C#(.Net/Mono, local application)?
Edition. We can identify mainboard in .Net using something like this (see Get Unique System Identifiers in C#):
using System.Management;
...
ManagementObjectSearcher searcher = new ManagementObjectSearcher("select * from Win32_MotherboardDevice");
...
But unfortunately Mono does not support System.Management. How to do it under Mono for Linux? - I don't know :(
Write a function that takes a few unique hardware parameters as input and generates a hash out of them.
For example, Windows activation looks at the following hardware characteristics:
Display Adapter
SCSI Adapter
IDE Adapter (effectively the motherboard)
Network Adapter (NIC) and its MAC Address
RAM Amount Range (i.e., 0-64mb, 64-128mb, etc.)
Processor Type
Processor Serial Number
Hard Drive Device
Hard Drive Volume Serial Number (VSN)
CD-ROM / CD-RW / DVD-ROM
You can pick up a few of them to generate your unique computer identifier.
Please see: Get Unique System Identifiers in C#
You realistically have MotherboardID, CPUID, Disk Serial and MAC address, from experience none of them are 100%.
Our stats show
Disk serial Is missing 0.1 %
MAC Is missing 1.3 %
Motherboard ID Is missing 30 %
CPUID Is missing 99 %
0.04% of machines tested yielded no information, we couldn't even read the computer name. It maybe that these were some kind of virtual PC, HyperV or VMWare instance, or maybe just very locked down? In any case your design has to be able to cope with these cases.
Disk serial is the most reliable, but easy to change, mac can be changed and depending on the filtering applied when reading it can change if device drivers are added (hyperv, wireshark etc).
Motherboard and CPUID sometimes return values that are invalid "NONE", "AAAA..", "XXXX..." etc.
You should also note that these functions can be very slow to call (they may take a few seconds even on a fast PC), so it may be worth kicking them off on a background thread as early as possible, you ideally don't want to be blocking on them.
Try this:
http://carso-owen.blogspot.com/2007/02/how-to-get-my-motherboard-serial-number.html
Personally though, I'd go with hard drive serial number. If a mainboard dies and is replaced, that PC isn't valid any more. If the HDD drive is replaced, it doesn't matter too much because the software was on it.
Of course, on the other hand, if the HDD is just moved elsewhere, the information goes with it, so you might want to look at a combination of serial numbers, depending what you want it for.
How about the MAC address of the network card?
I'd like to create a simple remote desktop application (you can view the screen remotely and interact with it). As a first step, I've tried taking screenshots, 1 per second, compressing them to JPEG and sending them over (without interaction), but I've found that even over LAN this is very slow.
Do you have any hints on how to do this better? Is there C# sample code for projects like this?
You might consider looking at VNC's implementation. VNC is open source and does what you want. I know of an open-source .NET client for VNC:
http://dotnetvnc.sourceforge.net/
Hopefully this will give you some direction for your project.
Just-in-time idea, if you don`t want to use vnc - and want to implement this yourself (for learning, how to invent wheels, for example) - send not full screenshot, but changes from previous - somethins like *.avi format (I forgot details, but something like: one full card, 15 changes, one full card, 15 changes and so on).