|
|
hmm i have seen this article but it seemed to b very difficult m beginner... but from this code i have selected some piece of code to light the LED. but not sure if it is ok or not.
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Threading;
using System.Timers;
namespace LED
{
public partial class Form1 : Form
{
public int i = 0, j = 0, adress = 888;
public Form1()
{
InitializeComponent();
Reset_LEDs();
}
private void Reset_LEDs()
{
PortAccess.Output(adress, 0);
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
int value = 0;
value += (int)Math.Pow(2, 0);
LoadNewPict_D0();
PortAccess.Output(adress, value);
}
}
}
what is LoadNewPict_D0(); function doing? will this piece of code ON the LED?
thanks 4 help
|
|
|
|
|
aeman wrote: value += (int)Math.Pow(2, 0);
Isn't that just 1 ?
aeman wrote: LoadNewPict_D0();
I think that's what's altering the images on the form he has, you don't really need it.
|
|
|
|
|
PIEBALDconsult wrote: Isn't that just 1 ?
Theoretically, yes. With all the rounding errors in floating-point math, who knows, it could be slightly less and get truncated to zero...
Why make things simple when you can make them look highly scientific?
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
at this time m chking with only 1 LED.
|
|
|
|
|
You might want to look into the shift-left operator anyway.
|
|
|
|
|
|
PIEBALDconsult wrote: Parallel Port
what is this parallel port you speak of?
is it that big connector I think I once saw in the Science Museum?
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
No, no, parallel connectors are actually rather petite, a mere twenty-five pins.
|
|
|
|
|
This better way of getting 1.
value += (int)(Math.Pow(Math.Sin(3.2), 2) + Math.Pow(Math.Cos(3.2), 2) + (8 / Math.Floor(8.7)) - 1);
|
|
|
|
|
Hi,
I've a university issued laptop with windows 7 on it. When I click on "windows" button it show my name as one of the system folder, but there is no path for it. It is above the "My Document" folder, in fact everyone in the university has same folder with their name [obviously]. I want to make an program that could extract the name of this folder when its it run on a particular system. And computer name, account name or name of Environment.getFolderName(SpecialFolder.Personal) all are different from this folder. I do not know where is this folder even stored.
CHECK THIS LINK FOR AN IMAGE
http://dl.dropbox.com/u/10120092/Untitled.png[^]
SHIVAM
|
|
|
|
|
There isn't a direct way, this however should give what you want:
string s=Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
s=s.SubString(0, s.Length-8);
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Shivam (/Luc);
You can access this folder with the SpecialFolder UserProfile ;
String s = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
|
|
|
|
|
Only if using .NET framework V4
|
|
|
|
|
Well the OP did not make reference to any .Net version, i don't know what he is using
[at least he knows now it exists in later frameworks!)
|
|
|
|
|
True.
I've had a look in reflector and it's easy enough to do this in previous versions - see my other answer[^] below
|
|
|
|
|
Hi, nothing seems to work. I tried your way, it only shows some other folder on my desktop.
|
|
|
|
|
try to be specific. What have you tried and what was the outcome?
What operating system, which .NET version, what exactly do you get, what exactly would you like to get.
It works for me!
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
I tried your code.
I get "C:\Users\100xxxxxx\Desktop" where 100xxxxxx is my student ID.
I'm using .Net 3.5 but I do have .Net 4 with visual studios 10. Not why it is not working for me..
S
|
|
|
|
|
And is there a folder somewhere that holds your actual name instead of your student ID?
All GetFolderPath() results are actual folder names.
When a user account gets created, the user name displayed is also used as the folder name; it is however possible to change one without changing the other, as explained e.g. here[^]. I guess that is what happened to the student accounts: first create them numerically, then modify their display names. The display name of the current user should be available through Environment.UserName
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Very strange but I do not see this folder anywhere on my computer. It shows when I press windows button or when I'm choosing or opening some file. I tried Environment.UserName but it is showing my student ID [LOL]. Anyways thanks, I checked your link, probably this what happening in my case too. DAM IT, but there has to be some folder which starts with my name.
Shivam
|
|
|
|
|
You're welcome.
BTW: Most of the username/foldername magic is hidden in the registry, as the article explains.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
YUPPII. I solved the problem. I searched my name inside the registry and found that everyone is school has same registry key to that their name as registry value..so in my program I'm reading the registry value from this registry key..and it is working fine..thanks everyone again..
SHIVAM
|
|
|
|
|
As an alternative to Luc's suggestion you can combine the SystemDrive and HOMEPATH environment variables something like this:
public static string GetUserFolder()
{
return
Environment.GetEnvironmentVariable("SystemDrive") +
Environment.GetEnvironmentVariable("HOMEPATH");
}
Edit: Just tested from explorer and using Process.Start and it appears to work with only the HOMEPATH variable too
|
|
|
|
|
Having seen Dave's answer that it is available in v4, I've had a look at how it's done using reflector and these two functions combined perform the same task and will work with earlier .NET versions so long as it's run on a platform that supports it - if not, a PlatformNotSupportedException will be raised.
public const int UserProfile = 40;
[DllImport("shfolder.dll", CharSet = CharSet.Auto)]
private static extern int SHGetFolderPath(IntPtr hwndOwner, int nFolder, IntPtr hToken, int dwFlags, StringBuilder lpszPath);
public static string GetUserPath()
{
StringBuilder resultBuilder = new StringBuilder(260);
int num = SHGetFolderPath(IntPtr.Zero, UserProfile, IntPtr.Zero, 0, resultBuilder);
if (num == -2146233031)
throw new PlatformNotSupportedException();
return resultBuilder.ToString();
}
|
|
|
|