|
You probably forgot to escape the application filespec. Instead of:
Process.Start ("C:\MyProg.exe");
use one of these options:
Process.Start ("C:\\MyProg.exe");
Process.Start (@"C:\MyProg.exe");
/ravi
|
|
|
|
|
Ya, there it is.
That and i forgot to put in the System.Diagnostics;
Thank you ravi
|
|
|
|
|
Well, without the source code, I would hazard a guess and say that you're not double-back-slashing your constant string like this: "C:\\Program Files\\Some Program Folder\\SomeExe.exe"
Am I "write"?
Of course, if this IS the case, I would suggest reading a little bit in a "learn to code in C in 21 days" or C# for dummies book...
If I am wrong, well, try posting some source code o we can see what you're doing wrong.
|
|
|
|
|
macerenn wrote: Am I "write"?
Ouch! <rolls over and gropes in the dark for a ham sandwich...>
/ravi
|
|
|
|
|
Ravi Bhavnani wrote: Am I "write"?
Looks like Cobol. Perhaps FileStream.CanWrite would work better
|
|
|
|
|
JohnnyLocust wrote: Looks like Cobol.
Mmmm... Cobol!
/ravi
|
|
|
|
|
Hello everyone,
I am working on a HTTP Sniffer. So far I am able to get some information on a TCP received packet using the following code.
MemoryStream ImemoryStream = new MemoryStream(byteBuffer, 0, nReceived);
BinaryReader IbinaryReader = new BinaryReader(ImemoryStream);
byteVersionAndHeaderLength = IbinaryReader.ReadByte();
byteDifferentiatedServices = IbinaryReader.ReadByte();
ushortTotalLength = (ushort)IPAddress.NetworkToHostOrder(IbinaryReader.ReadInt16());
ushortIdentification = (ushort)IPAddress.NetworkToHostOrder(IbinaryReader.ReadInt16());
ushortFlagsAndOffset = (ushort)IPAddress.NetworkToHostOrder(IbinaryReader.ReadInt16());
byteTTL = IbinaryReader.ReadByte();
byteProtocol = IbinaryReader.ReadByte();
ushortChecksum = IPAddress.NetworkToHostOrder(IbinaryReader.ReadInt16());
uintSourceIPAddress = (uint)(IbinaryReader.ReadInt32());
uintDestinationIPAddress = (uint)(IbinaryReader.ReadInt32());
I also need to get the URL address of where the packet are comming from. I have seen some comercial HTTP Sniffer being able to do that. The Sniffer80 available in http://www.codeproject.com/tools/sniffer80.asp[^] also can capture the URL address of the packet. Can someone tell me how I can get this done? Maybe I am looking for a URL address at the wrong place! Where can I get this information for a TCP packet then?
Any information on this would be great. As always, thank you for your help and have a great day.
Khoramdin
|
|
|
|
|
Well, the only thing I can think of when RECEIVING UNSOLICITED packets is to use reverse DNS. However, since you are "sniffing" HTTP, then it is simply a matter of catching all of the HTTP GET request headers, and mapping (an associative array) the actual IP address:port to the requested URL from the HTTP GET request header. Then, as packets come in from that IP, you retreive the URL by looking up the IP in your array... The thing is, in order to GET a TCP packet (using HTTP), you have to have made a GET request at some point: no unsolicited pushing of files onto your computer here. Every image and other resource on an HTML page is the result of a separate GET request. By the way, Sniffer80 is a piece of crap. It is not a sniffer. It is a cheap facade using URLMon. It is tied directly into IE. The source code is unnavailable, probably out of shame due to it's lame-ness. You could do the same by writing an IE add-in that copies the contents of the address bar...
Anyhow, if I am way off the mark here, let me know. It seems like a simple solution to me though, since you already have all the information at hand before the TCP packets even start flowing.
|
|
|
|
|
It's just that I don't like at all cut'n paste solutions... But seriously I am expecting that this file will change very often in the future and I like to be prepared.
I know that typdef is not a C# keyword. I meant I allready created a C++ Manged project and included the header into the project. After this project was compiled I reflected the dll but didn't find any typedefs there.
Regards,
Tobias
|
|
|
|
|
forget the typedef, and give the enum a name, as in:
namespace LP_ProgrammingLanguages {
public enum LP_Languages {
NONE=0,
ALL=0xFF00,
C=0x100,
...
}
}
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use PRE tags to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Is it possible to get the location of the Shortcut that the user used to launch the application?
"All of us who served in one war or another know very well that all wars are the glory and the agony of the young."
Gerald Ford
|
|
|
|
|
I don't think so. All i can suggest is checking if anything is in the arguments (y'know, string[] args). There's also Application.StartupPath but i imagine that will just return the path to your application. Its worth a look.
My current favourite word is: PIE!
I have changed my name to my regular internet alias. But don't let the 'Genius' part fool you, you don't know what 'SK' stands for.
-The Undefeated
|
|
|
|
|
Hello.
I've wrote recently program which swiches desktop wallpaper every eg. 5 minutes. Everything works well, but I've got one hard problem.
In my program options i can choose style of wallpaper (Tiled, Centred, Stretched).
And now when I'm setting wallpaper Centred and user click RMB on Desktop and choose option "Hide Icons On Desktop". Icons disappear and wallpaper that I have set is chanding from Centered to Tiled. It doesn't happen with stretched or tiled (of course) option.
I checked and when I choose style of wallpeper in Desktop Properties (not in my program) and then hide icons, everything is ok.
I'm totally confused.
I use class below which I've found at CP.com and modified a bit:
public sealed class Wallpaper<br />
{<br />
public Wallpaper() { }<br />
<br />
const int SPI_SETDESKWALLPAPER = 20;<br />
const int SPIF_UPDATEINIFILE = 0x01;<br />
const int SPIF_SENDWININICHANGE = 0x02;<br />
<br />
[DllImport("user32.dll", CharSet = CharSet.Auto)]<br />
static extern int SystemParametersInfo(int uAction, int uParam, string lpvParam, int fuWinIni);<br />
<br />
public enum Style : int<br />
{<br />
Tiled,<br />
Centered,<br />
Stretched<br />
}<br />
<br />
public static void Set(Uri uri, Style style)<br />
{<br />
System.IO.Stream s = new WebClient().OpenRead(uri.ToString());<br />
<br />
System.Drawing.Image img = System.Drawing.Image.FromStream(s);<br />
string tempPath = Path.Combine(Path.GetTempPath(), "wallpaper.bmp");<br />
img.Save(tempPath, System.Drawing.Imaging.ImageFormat.Bmp);<br />
<br />
RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Control Panel\Desktop", true);<br />
if (style == Style.Stretched)<br />
{<br />
key.SetValue(@"WallpaperStyle", 2.ToString());<br />
key.SetValue(@"TileWallpaper", 0.ToString());<br />
}<br />
<br />
if (style == Style.Centered)<br />
{<br />
key.SetValue(@"WallpaperStyle", 1.ToString());<br />
key.SetValue(@"TileWallpaper", 0.ToString());<br />
}<br />
<br />
if (style == Style.Tiled)<br />
{<br />
key.SetValue(@"WallpaperStyle", 1.ToString());<br />
key.SetValue(@"TileWallpaper", 1.ToString());<br />
}<br />
<br />
SystemParametersInfo(SPI_SETDESKWALLPAPER,<br />
0,<br />
tempPath,<br />
SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE);<br />
}<br />
}
and I use such instruction:
Wallpaper.Set(new System.Uri("c:\\tap.jpg"), Wallpaper.Style.Centered);
thanks for all responses.
|
|
|
|
|
hey my[Hope not to bother anyone] people,
I would like to Authenticate a user in the main form application[client] and then in the server. And also i would like to authorize the users. I don't have webforms... i have desktop applications which connects to the Internet and communicate one to each other.
Say i would like to:
1 - Send the SID of each computer where the client is running
2 - Send the login information of the current user
3 - Verify the current user of the Client has Administrator rights from the server
4 - Verify the publisher of the application. I am thinking that if i verify the publisher i can use the certificate, is that right?
5 - Digitally sign and verify all data that is being sent over the network.
I know how to sign all data but i am not so sure how to verify it.
would this be possible:
.
.
.
byte[] toSend = Encoding.ASCII.GetBytes(Convert.ToString(WindowsIdentity.GetCurrent()));
NetworkStream net = ClientTCP.GetStream();
try{
net.Write(toSend,0,toSend.Length);
}
catch{}
finally
{
net.Close();
ClientTcp.Close();
}
...
in the other side i would have a receiving part but i would like to do this:
try{
int bytes = net.Read(toRead,0,toRead.Length);
string iden = Encoding.ASCII.GetString(toRead,0,bytes);
//assuming that i have all the bytes of the windows identity
WindowsIdentity W_iden = (WindowsIdentity) iden;
}
would that code help me send a windows identity over the network????
thanks all...
regards
The way of the code warrior is... SO beginning of the legacy starts now!
|
|
|
|
|
The only true way to authenticate is if two parties know who they should be talking to prior to initiating the conversation. Then, both parties can sign all communications between them with their "private key" to ensure they are who they say they are. Other schemes have been produced which attempt to get around knowing anything about someone else before communicating, but they are all able to be cracked in one way or another. The most secure way to set it up would be to store all user public keys, and have all users store the server public key. Then, each user communicates by hashing the message, signing the hash, creating a symmetrical key, encrypting the sym key with the other party's public key, then encrypting the message with the symmetrical key, and sending the information to the other party.
Jeff
|
|
|
|
|
Hello,
I have the problem that I have a lengthy c header file containing something like:
<br />
typedef enum<br />
{<br />
enum1,<br />
enum2,<br />
enum3,<br />
... a lot more<br />
} MyEnums;
How can I best reuse this information in my CS projects without cut'n paste or even retype this?
Thanks,
Tobias
|
|
|
|
|
hi,
two ideas:
1.
write a little program to rework the source file
or
2.
compile as a C++/CLI dll, decompile with reflector towards C# source.
(this will loose all comments, assuming you have them; not clear from your post).
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use PRE tags to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Thank you for your post, I allready tried the second solution, but didn't succeed. I didn't find the typedef enum in the reflected dll. Do you know how excactly I need to include the typedef?
Tobias
|
|
|
|
|
You can't. typedef is a C keyword and not C#. As Luc said, you could use C/CLI to get this. Why can you not cut/paste this code?
|
|
|
|
|
Hmmm.... as far as the enum is concerned; perhaps a RegEx to extract it and rewrite it in C# syntax?
An interesting little project, I may have to try it.
|
|
|
|
|
Usually a typedef is defined in another header, take a look at the original type of the typedef, then you can properly assign that type in C#.
Any code will be useful
Microsoft Student Partner
|
|
|
|
|
how do i point a sub domain to a specified folder?
i need a solution that the web application should handle that, not IIS, since i don't have permission to change the IIS settings.
|
|
|
|
|
You might want to ask in the ASP.NET forum on this site.
"I've seen more information on a frickin' sticky note!" - Dave Kreskowiak
|
|
|
|
|
Bold, Copy and paste works fine but when i bold the text and click on copy and then paste text on a new line the text formation is gone. It just paste the acutal text but loose the Bold format. Am i doing something wrong in my codes.<br />
<br />
mshtml.HTMLDocument doc=(mshtml.HTMLDocument)this.axWebBrowser1.Document;<br />
doc.execCommand("Bold",false,null);<br />
doc.execCommand("Copy", false, null);<br />
<br />
text=Clipboard.GetDataObject().GetData(DataFormats.Text,true).ToString();<br />
doc.execCommand("Paste", false, text);
thanks
|
|
|
|
|
I think you should be using DataFormats.Rtf to get the data from the clipboard
Jeff
|
|
|
|
|