|
thanks david. i wont do it.. i saw a guys source (it was a tourial) he had a way to detect if the file was encrypted or not.. i orignally though there was a way to detect which encryption was being used. but reviewing the code i do see that he added a flag into each file. it was a boolean number (011011 or something) while that does over some security... if i could crack that number and know that means "des" encryption to the program then someone else could too. anyways.. thanks agian.
|
|
|
|
|
Hi.
Like you said, I would just go with the flag describing the file if I were you. It doesn't reduce the security of the file at all if you are using industry standard encryption methods like 3des or Rijndael. Infact, you should write your security routines with the full knowledge that a hacker WILL be able to deduce exactly what techniques you are using in your system. The secret it to use techniques that are hard to break even if you do know the algorithm.
Just use the flag.
Pete
Insert Sig. Here!
|
|
|
|
|
how to get ip address of different computers on the network?
r00d0034@yahoo.com
|
|
|
|
|
You can only get the IP if you have the DNS of the computer, or the MAC address. You have to use System.Net classes for this.
|
|
|
|
|
Anyone have an "efficient" routine for stripping punctuation for a string?
Mike Stanbrook
mstanbrook@yahoo.com
|
|
|
|
|
public string StripPunctuation(string source)
{
string pattern = "[^a-zA-Z ]";
System.Text.RegularExpressions.Regex regex;
regex = new System.Text.RegularExpressions.Regex(pattern);
return regex.Replace(source, "");
}
That should do it. I think .NET's regular expression classes are effiecient enough.
1001111111011101111100111100101011110011110100101110010011010010 Sonork | 100.21142 | TheEclypse
|
|
|
|
|
Why not just rewrite:
string pattern = "[^a-zA-Z ]";
System.Text.RegularExpressions.Regex regex;
regex = new System.Text.RegularExpressions.Regex(pattern);
return regex.Replace(source, "");
As
Regex regex = new Regex("[^a-zA-z]");
regex.Replace(source, "");
Makes things a lot simpler if you skip the first string and move the declaration and instantiation on to one line.
I don't know whether it's just the light but I swear the database server gives me dirty looks everytime I wander past.
-Chris Maunder
Microsoft has reinvented the wheel, this time they made it round.
-Peterchen on VS.NET
|
|
|
|
|
|
Bah, it's all the same IL-wise.
I don't know whether it's just the light but I swear the database server gives me dirty looks everytime I wander past.
-Chris Maunder
Microsoft has reinvented the wheel, this time they made it round.
-Peterchen on VS.NET
|
|
|
|
|
Hi there
I was wondering if it is possible to customize the title bar, buttons etc. in a Form. I want to change the color and maybe draw my own "maximize" button etc. The user should still be able to do all the "normal" things with the form, like changing the position.
Really appreciate if someone could help me!
Sincerely
Pat
|
|
|
|
|
The only way I know of to do this is to set the FormBorderStyle to None. Then, add controls and modify their behavior and appearance however you want.
This probably isn't the answer you were looking for, but I hope it helps.
-Steve
|
|
|
|
|
The caption bar and the maximize, minimize, close buttons are drawn by the windows operating system. I did some research, and there is very little you can do about it. The only way you can do it is to make a form with no border, make your program skinable (which is a pain), and add draging and resizing support.
At least this is the way I had to do it. If there is a better way tell me too.
|
|
|
|
|
anotherside2000 wrote:
I was wondering if it is possible to customize the title bar, buttons etc.
What about checking out the CodeProject articles about Balloon Windows with C# ?
When you know a Form is mostly an oriented-object event-based class running on top of a standard WIN32 Window, you can figure out that this is possible.
The form is created with hardcoded window styles (managed by an hardcoded default .NET System.Windows.Forms.CreateParams instance). But, once that form is created (this.Handle!=0), you could just start hacking the underlying window just like with C/C++ code. For that purpose, use P/Invoke unsafe native methods like SetWindowStyle, ...
You'll need the hwnd of that window : that's this.Handle (cast the returned IntPtr to an int if you like).
Be also sure to Hide the SizeGrip (drawn around the window) with a simple this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
Good luck!
|
|
|
|
|
Thank you all for the help!
Appreciate it
Sincerely
Pat
|
|
|
|
|
Why this code freeze the application ?
Best wishes and happy new year.
//////////////////////////////////////////////////////////////////////////////////
using System.Runtime.InteropServices;
public class...
{
[DllImport("wininet.dll")]
public static extern bool InternetGetConnectedState(int lpdwFlags, int dwReserved);
...
bool res;
res = InternetGetConnectedState(0, 0);
switch (res)
{
case true:
MessageBox.Show("Connecté");
break;
case false:
MessageBox.Show("Non connecté");
break;
}
}
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
That should be:
[DllImport("wininet.dll")]
public static extern bool InternetGetConnectedState(
out int lpdwFlags, int dwReserved);
...
int flags;
bool ret = InternetGetConnectedState(out flags, 0);
...
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
|
|
|
|
|
Im still confused and going round in circles with this stuff. Bear with me as I explain what I have done and am doing.
What I am attempting to do is write a "quick and dirty" MAPI Service Provider to implement a mail sender that posts via an XML interface over HTTP. The XML interface over HTTP bit is working already.
Now, my thought was "Well, .NET does XML nicely so I don't have to get dirty with that stuff", and so I decided to learn what was involved in writing a service provider.
Step 1: Read all about it
- In this case, this meant digging up a copy of "Inside MAPI", which is apparently the only book on writing service providers. I tried going through the MSDN collection, but - quite frankly - in this area, it sucks (altho I did come across an article saying "MAPI isn't dead yet", which is heartening).
Now, in reading, I learnt that I needed to do the following:
- Code a Windows DLL with implements ServiceEntry() and XPProviderInit() and three COM interfaces (IXPProvider, IXPLogon and IMAPIStatus, all of which seem to inherit IUnknown).
I figured here that ServiceEntry() and XPProviderInit() will have to be in some class - probably the "default" class, if such a beast exists - since these will kick off Windows Forms for configuration dialogs, this shouldn't really be the stumbling block.
So I decided my first task was coding the .NET replacements for IXPLogon, IXPProvider, and IMAPIStatus. This is where I get confused, and Microsofts reference turns me round and round in a circular mess until I am confused.
Thus far, I get to the following code, which I think is right
<br />
using System;<br />
using System.Runtime.InteropServices;<br />
<br />
namespace MAPI.Extended<br />
{<br />
[Guid("insert-my-generated-guid-here")]<br />
interface IXPLogon<br />
{<br />
void Shutdown(UInt32 lpulFlags);<br />
<br />
}<br />
}<br />
Now, this last one has me more than a little concerned, but I figure that if I can work this one out, then I am in good shape for the other ones. The MSDN documentation says ULONG becomes a UInt32, LPTSTR becomes a String - this is fairly easy.
LPMAPISUP is a pointer to an object which implements IMAPISupport. Thus, I figure I can replace that with IMAPISupport lpMAPISup possibly? LPXPLOGON is a similar (IXPLogon) object, so I figure I can replace that with IXPLogon lppXPLogon... or do I need to replace these with something else because they are pointers? (Im confused).
How about ULONG FAR *? I know ULONG => UInt32, but what about a pointer? Do I do a ref? That MAPIERROR is a pointer to an enum (I think), so I define the MAPIERROR enum and reference it here?
In other words, here is what I *think* it should look like:
<br />
using System;<br />
using System.Runtime.InteropServices;<br />
<br />
namespace MAPI.Extended<br />
{<br />
[Guid("insert-my-generated-guid-here")]<br />
interface IXPLogon<br />
{<br />
void Shutdown(<br />
ref UInt32 lpulFlags);<br />
<br />
void TransportLogon(<br />
IMAPISupport lpMAPISup,<br />
UInt32 ulUIParam,<br />
string lpszProfileName,<br />
ref UInt32 lpulFlags,<br />
ref MAPIERROR lppMAPIError,<br />
ref IXPLogon lppXPLogon);<br />
}<br />
}<br />
How close am I?
|
|
|
|
|
Hi all,
I've been working on a problem for the last while and I think I'm after backing myself into a nasty corner. Anyway, is it possible to serialize and de-serialize an ArrayList object?
Thanks for yeer help.
Johnny
|
|
|
|
|
worked fine for me... and its marked [serializable] in the help docs....
Some ideas are so stupid that only an intellectual could have thought of them - George Orwell
|
|
|
|
|
I've been working on getting the CreateProcessWithLogonW System call to work, and have been having trouble. What I have now always generates a Windows error #87 (Invalid Parameter). Can anyone help? This is the relevant code:
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
private struct STARTUPINFO
{
public int cb;
public string lpReserved;
public string lpDesktop;
public string lpTitle;
public int dwX;
public int dwY;
public int dwXSize;
public int dwYSize;
public int dwXCountChars;
public int dwYCountChars;
public int dwFillAttribute;
public int dwFlags;
public int wShowWindow;
public int cbReserved2;
public int lpReserved2;
public int hStdInput;
public int hStdOutput;
public int hStdError;
}
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
private struct PROCESS_INFORMATION
{
public int hProcess;
public int hThread;
public int dwProcessId;
public int dwThreadId;
}
[DllImport("advapi32.dll", CharSet=CharSet.Unicode)]
private static extern bool CreateProcessWithLogonW(
String lpUsername,
String lpDomain,
String lpPassword,
int dwLogonFlags,
String lpApplicationName,
String lpCommandLine,
int dwCreationFlags,
IntPtr lpEnvironment,
String lpCurrentDirectory,
STARTUPINFO lpStartupInfo,
PROCESS_INFORMATION lpProcessInfo);
...
bool b = CreateProcessWithLogonW(UserName, Domain, Password, 1, "c:\\winnt\\system32\\cmd.exe, null, 1, (IntPtr)null, null, si, pi);
|
|
|
|
|
Two things I can see might help:
1. You probably need to initialize the cb member of your STARTUPINFO structure to sizeof(STARTUPINFO). Not that this is considered "unsafe". Not bad, you just need to enclose the statement in an unsafe block.
Declare the STARTUPINFO and PROCESS_INFORMATION arguments as "ref". You'll also need to put the word ref in the argument list when you call it.
|
|
|
|
|
OK, I've changed the code so it looks like this now:
[DllImport("advapi32.dll", CharSet=CharSet.Unicode)]
private static extern bool CreateProcessWithLogonW(
String lpUsername,
String lpDomain,
String lpPassword,
int dwLogonFlags,
String lpApplicationName,
String lpCommandLine,
int dwCreationFlags,
IntPtr lpEnvironment,
String lpCurrentDirectory,
ref STARTUPINFO lpStartupInfo,
ref PROCESS_INFORMATION lpProcessInfo);
int size = si.cb = Marshal.SizeOf(typeof(STARTUPINFO));
bool b = CreateProcessWithLogonW(UserName, Domain, Password, 1, Application, null, 1, (IntPtr)null, null, ref si, ref pi);
It's still failing with error #87...any other ideas?
|
|
|
|
|
I hope this is an easy question:
How do i find the screen resolution in .NET?
I want to make sure that if the resolution was reduced, my program won't come up out of the visible range.
Thanks,
Steve
|
|
|
|
|
you can get the rectangle that defines the desktop boundaries with
Rectangle DTRect = Screen.GetBounds();
To get the working area (destop minus taskbar and docked windows):
Screen.GetWorkingArea(Screen.GetBounds());
Some ideas are so stupid that only an intellectual could have thought of them - George Orwell
|
|
|
|
|
Thanks. I knew it would be something obvious like "Screen". I kept trying to find a "Display" object.
-Steve
|
|
|
|
|