|
In order to help you with this, you must post the source code you are using for encryption / decryption. Do that and I'll see what I can do to help.
|
|
|
|
|
The following is the source code that I wrote to set up my encryption class. This works independently of the entire program and will successfully encrypt and decrypt any byte array I pass through it. However, when I encrypt a file attach it to an email and then decrypt that file when recieved. I lose the data.
using System;
using System.Security.Cryptography;
using System.IO;
using System.Text;
namespace crypt.Cryptography
{
class SymCryptography
{
private string _Key;
public SymCryptography()
{
}
public string EncryptionKey
{
get
{
return _Key;
}
set
{
_Key = value;
}
}
public byte[] Encrypt(byte[] source)
{
byte[] EncryptedFile= null;
byte[] encryptedKey = this.getKeyBytes();
SymmetricAlgorithm rijn =SymmetricAlgorithm.Create();
//Creates the default implementation, which is
//RijndaelManaged.
MemoryStream encryptContainerMS = new MemoryStream();
CryptoStream encryptStream = new CryptoStream
(encryptContainerMS,rijn.CreateEncryptor(encryptedKey,
encryptedKey),CryptoStreamMode.Write);
encryptStream.Write(source,0,source.Length);
encryptStream.FlushFinalBlock();
encryptStream.Close();
EncryptedFile = encryptContainerMS.ToArray();
return EncryptedFile;
}
private byte[] getKeyBytes()
{
UnicodeEncoding UE = new UnicodeEncoding();
return UE.GetBytes(this._Key);
}
public byte[] Decrypt(byte[] source)
{
byte[] DecryptedFile= null;
byte[] encryptedKey = this.getKeyBytes();
SymmetricAlgorithm rijn= SymmetricAlgorithm.Create();
//Creates the default implementation, which is
// RijndaelManaged.
MemoryStream decryptContainer = new MemoryStream();
CryptoStream decryptStream = new CryptoStream(decryptContainer,
rijn.CreateDecryptor(encryptedKey, encryptedKey),
CryptoStreamMode.Write);
decryptStream.Write(source,0,source.Length);
decryptStream.FlushFinalBlock();
decryptStream.Close();
DecryptedFile = decryptContainer.ToArray();
return DecryptedFile;
}
}
}
thanks for the help.
Trevor
|
|
|
|
|
Greetings most excellent programmers!
Welcome to a challenge, my own promotion depending challenge.
Herein lies the challenge that nurtures a very enticing reward...
The Challenge:
A program that will intercept the keyboard and mouse events,
that will have a GUI to allow building sequences of mouse & keyboard events,
that will bewitch any program into thinking that they're receiving the
normal inputs of the keyboard & mouse instead of a cleverly construed script.
The challenge is, in short, to take over the Keyboard&Mouse of Windows XP.
To build and run in a loop sequences of mouse and keyboard events.
In the end, to simulate the activity of a user in any program.
This isn'T a screencapture device. Its an app that must wrap and control the IO of the Keyboard & mouse on a level that allows to control what normal programs receives as keyboard & mouse input.
Where to start?
Thanks for your help!
Orlanda
|
|
|
|
|
Orlanda Ramos wrote:
A program that will intercept the keyboard and mouse events,
that will have a GUI to allow building sequences of mouse & keyboard events,
that will bewitch any program into thinking that they're receiving the
normal inputs of the keyboard & mouse instead of a cleverly construed script.
You are describing a screen recording tool (among which Mercury WinRunner, Rational Robot, Silk, ...).
You also have a free code on MSDN [^] to begin with. (probably the best thing you'll come across for 0 dollar).
Orlanda Ramos wrote:
have to build this program and I ask for your advice or guidelines.
This is a very important project for my career, this is challenge.
And with your advice I hope, perhaps to overcome this challenge.
Skip such things in the future. allright?
|
|
|
|
|
im no expert, but isnt that what the SendMessage . look it up in MSDN.
1001111111011101111100111100101011110011110100101110010011010010 Sonork | 100.21142 | TheEclypse
|
|
|
|
|
My question has 2 part:
1-How can I stop moving from one cell to another in a DataGrid (from
left to right)
2- When a cell that displays text is selected in a DataGrid, the text
portion of the cell is always selected, the part of the cell that
has no text isn't. I would like the whole background of the cell to
be the same(the text portion and the portion without text).
I overrode the Paint method of the DataGridTextBoxColumn with so
so success. The background of the selected text portion of a
cell is always different from the rest of the cell.
As for part 1 of my message, I really don't know how to do it.
I someone could help, it would be appreciated
Thanks,
Nick stone
C# newbie
|
|
|
|
|
Has anyone come across a free class/library/engine (including source code in c#) that will allow me to use xml files as a database (possible supporting SELECT, INSERT, UPDATE style operations).
It doesn't have to be anything fancy, only needs to support one user and must be free.
I want to use XML files as a replacement for Microsoft Access database files in a single user application.
Cheers in advance.
|
|
|
|
|
I haven't messed with it yet, but the first thing I would try is DataSet.ReadXml , DataSet.GetXml , DataSet.ReadXmlSchema , DataSet.WriteXml , DataSet.WriteXmlSchema , etc.
Mark Sanders
sanderssolutions.com
|
|
|
|
|
TeaTime wrote:
Has anyone come across a free class/library/engine (including source code in c#) that will allow me to use xml files as a database (possible supporting SELECT, INSERT, UPDATE style operations).
I think you need to look into XPath.
-Nick Parker
|
|
|
|
|
I have a MainForm. In this mainform is a menulike UserControl TreeView or ListBox. When the user choses a MenuItem a ChildForm in the mainform is shown where the user can input some data. Now I would like that the UserInterface acts as follows: the user should be able to access MenuItems by Key (say ALT+X) without that the MenuControl must have the focus.
So how can I get every Keyboard Input from any form or any control?
I would like to check these inputs for special key ALT and then switch to chosen MenuPoint.
I tried with MDIContainer-Form but didn't seam to be very usefull for this problem.
Any suggestions are very welcome!
Thanks
Stefan
|
|
|
|
|
Hi,
I have a DataGrid Bound to a table. How can I update my table after a row has been selected and deleted from the grid?
I tryed the following (but it did not work):
CurrencyManager cm = (CurrencyManager)this.BindingContext[myDatagrid.DataSource, MydataGrid.DataMember];
cm.EndCurrentEdit();
cm.Refresh();
SqlDataAdapter da = new SqlDataAdapter();
da.Update(myTableBoundToTheDatagrid);
Let's say i have 1 row in my table, I delete it from the grid, I still have one row in my table, after running the code above.
Thanks for any comment,
Yann
|
|
|
|
|
The following should work
DataSet something = GetSomethingFromTheDB();
myDataGrid.DataSource = something;
//Allow deletes from the grid..
SqlDataAdapter da = new SqlDataAdapter();
da.Update(something);
|
|
|
|
|
I need to programmatically retrieve IP configuration information using the IP Helper APIs GetNetworkParams() from C#.
Everytime I call the function all I get back is a value of 87
I come from a Java background and I am unfamiliar with both structs and DLL's.
Below is my code, I would appreciate it if someonce code provide me with a working implementation or pointers to what I am doing wrong;)
The results of running the code are
UNKNOWN ERROR => 87
bufferSize => 9999999999999999999
error => 87
using System;
using System.Runtime.InteropServices;
namespace dlltest
{
public class IpHelperTest
{
public const int ERROR_BUFFER_OVERFLOW = 111;
[DllImport("IPHLPAPI.DLL")]
public static extern long GetNetworkParams(ref FIXED_INFO buf, ulong cbRequired);
public IpHelperTest()
{
ulong bufferSize = 9999999999999999999;
FIXED_INFO Info = new FIXED_INFO();
long error = GetNetworkParams(ref Info, bufferSize);
if(error == ERROR_BUFFER_OVERFLOW)
{
Console.WriteLine("BUFFER OVERFLOW => "+error);
}
else if(error == 0)
{
Console.WriteLine("GOT INFO");
}
else
{
Console.WriteLine("UNKNOWN ERROR => "+error);
}
Console.WriteLine("bufferSize => "+bufferSize);
Console.WriteLine("error => "+error);
}
[StructLayout(LayoutKind.Sequential)]
public struct IP_ADDR_STRING
{
long dwNext;
String IpAddress;
String IpMask;
long dwContext;
}
[StructLayout(LayoutKind.Sequential)]
public struct FIXED_INFO
{
String HostName;
String DomainName;
IP_ADDR_STRING CurrentDnsServer;
IP_ADDR_STRING DnsServerList;
long NodeType;
String ScopeId;
long EnableRouting;
long EnableProxy;
long EnableDns;
}
public static void Main()
{
IpHelperTest ipHelperTest = new IpHelperTest();
}
}
}
|
|
|
|
|
In an application that I am writing I am loading lots of different forms and Windows XP groups those forms, when there are too many for the Taskbar. I have set different properties of my projects but no text appears on the grouping.
Does anyone know what property I have to set to create the grouping name?
Thanks
Adam
|
|
|
|
|
I will add an event property for all my MenuItem objects. To do this, I add an IExtenderProvider derived class to my application and implement the Get, Set and CanExtend methods. This work fine except that the event property cannot be edited in the event property tab! It is also grayed in the attribute property tab! Has some body an idee how to use IExtenderProvider with events ?
<br />
using System;<br />
using System.ComponentModel;<br />
using System.Collections;<br />
using System.Diagnostics;<br />
using System.Windows.Forms;<br />
<br />
namespace MenuProperty<br />
{<br />
public interface IUpdateUI<br />
{<br />
void Enable(bool enable);<br />
void Check(bool check);<br />
}<br />
<br />
public delegate void EventUpdateUI(IUpdateUI updateUI, EventArgs e);<br />
<br />
[<br />
ProvideProperty("UpdateUI", typeof(Component)),<br />
]<br />
public class MenuUpdateUI : System.ComponentModel.Component, IExtenderProvider<br />
{<br />
Hashtable dictionaryUpdateUI = new Hashtable();<br />
<br />
public void SetUpdateUI(Component component, EventUpdateUI updateUI)<br />
{<br />
if (updateUI != null && !dictionaryUpdateUI.Contains(component))<br />
{<br />
dictionaryUpdateUI.Add(component, updateUI);<br />
MenuItem menuItem = (MenuItem)component;<br />
}<br />
}<br />
<br />
public EventUpdateUI GetUpdateUI(Component component) <br />
{<br />
if (dictionaryUpdateUI.Contains(component))<br />
return (EventUpdateUI)dictionaryUpdateUI[component];<br />
return null;<br />
}<br />
<br />
public bool CanExtend(object obj)<br />
{ <br />
return (obj is MenuItem);<br />
} <br />
}<br />
}<br />
|
|
|
|
|
Hi all,
I want to have 4 coulmns in my data grid. Three columns listing strings and the fourth column must have checkbox.
I don't have a database behind. [And from what I understand we have to specify some datasource to display results in the grid]. I do a search on certain properties in instances of my own class and I want to list the serach results in the datagrid. I can populate the search results in an array and assign the datasource of the grid to this array. But to display results as four columns I need an 1 X 4 array. But the datagrid shows runtime error saying the array is not one dimensional
Is there an easy way out ? What is the best way to display my results? Is it grid or something else ? In the case of grid, how will I assign my 1 X 4 array to the grid ?
Thanks
Smitha
Imagination is more important than knowledge.
--Albert Einstein
|
|
|
|
|
:-OHi!
Try filling it via DataTable! or simply add rows manually.
<br />
<br />
ICollection CreateDataSource() <br />
{<br />
DataTable dt = new DataTable();<br />
DataRow dr;<br />
<br />
if(Read())<br />
{<br />
for(int i=0;i<myReader.FieldCount;i++)<br />
{<br />
dt.Columns.Add(<br />
new DataColumn(<br />
myReader.GetName(i)));<br />
}<br />
<br />
do<br />
{<br />
dr = dt.NewRow();<br />
for(int i=0;i<myReader.FieldCount;i++)<br />
{<br />
dr[i] = myReader.GetValue(i);<br />
}<br />
dt.Rows.Add(dr);<br />
}while(Read());<br />
<br />
}<br />
<br />
DataView dv = new DataView(dt);<br />
<br />
return dv;<br />
} <br />
<br />
...
dg1.DataSource = CreateDataSource();<br />
dg1.DataBind();<br />
Checkbox: try itemtemplates. Edit your aspx file.
Agyklon
|
|
|
|
|
You may to create a DataTable from array and use it as a datasource. Sorry, it isn't too smart ...
Hi,
AW
|
|
|
|
|
Thanks for the help guys
Smitha
The future belongs to those who believe in the beauty of their dreams.
--Eleanor Roosevelt
|
|
|
|
|
Create a blank project, set the WindowState to minimized in the designer and in the form1_load event put this.Hide();
Now why do I get different behavior when I keep the WindowState to Normal but add this.WindowState = FormWindowState.Minimized; this.Hide();
to the form1_load event?
Aren't they the same thing?
|
|
|
|
|
I have created a MDI parent form which has a UserControl
inside.
I create two instances of the form with the UserControl as
mdi children.
I shrink them down vertically so scroll bars appear. Then
drag the scrollbars down to the bottom of the form.
Select one child form, and then select another child form,
in effect, changing focus between the two forms.
When I click on one child, then another, the contained
UserControl jumps and the scroll bar moves to reposition
the contents of the form.
I do not see this behavior if I use a label instead of a
user control.
I dont want the contents of the child form to be
repositioned when you change focus to/from a child.
Having this behavior really breaks my app; I cannot have
windows automatically moving contents after a user has
carefully positioned the windows and the scroll bars where
they want them.
How can I keep the contents of a form with a UserControl
in the same place even if the user moves around between
different MDI child windows?
I saw mention of a known bug in .NET that was described as
follows from the following link:
http://www.windowsforms.com/Forums/showpost.aspx?
tabindex=1&tabid=41&PostID=261
Case in point, killing that annoying autoscroll reset to
upper left corner on a scrollable control recieving focus.
Took me about 8 hours to work around it; the simple
override of WndProc to ignore WM_SETFOCUS seemed OK at
first, but screwed up the setting of the active control
property. If I had access to source, it would have taken
me all of 5 minutes to find the proper workaround (setting
the scroll state to manual during the WM_SETFOCUS handler)-
-
Can anyone suggest what is going on here, and perhaps give
me a start on how to fix the problem? I am not familiar
with overriding Wndproc.
|
|
|
|
|
I need to copy and send the data in a private structure from an MFC app to a .NET app. Somehow, the following does not seem to work. When I use the WM_COPYDATA windows message as indicated below, it is not being received by the WndProc on the .NET side, but when I use a private message, it is received. Unfortunately, when I use the private message, the data seems not to be copied across and I get an assertion error for null data. WM_COPY is not received on the .NET side, but when a private message is used, it is received but then Marshal.PtrToStructure asserts reporting a null value.
Using COM interop is not an option. The client thinks that COM will slow things down as the function is called thousands of times.
Does any one have a suggestion, or a better approach?
Thanks
Gaul
****************************
ON THE MFC SIDE
****************************
////////////////////////////////////////////////////////////
// Increment is called on the MFC side
/////////////////////////////////////////Increment Counter
long CTSPerfMon::Increment(int objectID, int instID)
{
_msg.nMsgID = TS_MSG_INCREMENT;
_msg.nObjectID = objectID;
_msg.nInstID = instID;
_msg.nValue = -1;
return SendMessage();
}
// Send Message across to the .NET side module
long CTSPerfMon::SendMessage()
{
// Fill the WIN32 COPYDATASTRUCT structure
_copyData.dwData = _nPerfMsg; // Message identifier
_copyData.cbData = sizeof(_msg); // size of data
_copyData.lpData = &_msg; // data structure
// Call function, passing data in &_msg
long nRetCode = -1;
if ( _hPerfWnd != NULL )
{
HWND hWnd = GetForegroundWindow();
if (hWnd == NULL)
hWnd = GetDesktopWindow();
nRetCode = ::SendMessage( _hPerfWnd,
WM_COPYDATA, //private message works here
(WPARAM)(HWND) hWnd, //windows sending the data
(LPARAM)(LPVOID) &_msg);
}
return nRetCode;
}
****************************
ON THE C# .NET SIDE
****************************
protected override void WndProc(ref System.Windows.Forms.Message m)
{
if (m.Msg == (int) Msgs.WM_COPYDATA)
{
COPYDATASTRUCT copyData = (COPYDATASTRUCT) Marshal.PtrToStructure(m.LParam, typeof(COPYDATASTRUCT));
if ((object) copyData != null)
{
IntPtr nPerfMsg = copyData.dwData;
if (nPerfMsg.ToInt32() == _nPerfMsg)
{
TSMSG msg = (TSMSG) Marshal.PtrToStructure(copyData.lpData, typeof(TSMSG));
int nRetCode = ProcessMessage(ref msg);
m.Result = (IntPtr) nRetCode;
return;
}
}
}
base.WndProc(ref m);
}
Structure definition on the MFC C++ side
----------------------------------------
#ifdef __cplusplus
extern "C" { // Assume C declarations for C++
#endif
typedef struct tagTSMSG
{
int nMsgID;
int nObjectID;
int nValue;
int nInstID;
}TSMSG;
#ifdef __cplusplus
} // End of extern "C" {
#endif // __cplusplus
Structure definitions on the .NET side:
--------------------------------------
[StructLayout(LayoutKind.Sequential)]
public struct TSMSG
{
public int nMsgID;
public int nObjectID;
public int nValue;
public int nInstID;
}
[StructLayout(LayoutKind.Sequential)]
public struct COPYDATASTRUCT
{
public IntPtr dwData;
public int cbData;
public IntPtr lpData;
}
Gaulles
|
|
|
|
|
I have a treeview/listview combo I’m using as a mechanism to select folders and files to become the contents of a “backup job” file. Every entry in the treeview and listview has a checkbox next to it for selection.
This job file will be used by a windows service that will wake up, read the job file and copy folder/files to another mapped drive according to the contents of the job file….
I need to build some sort of string array or linked list that can grow/shrink dynamically, that mirrors the user’s selections… so every time the user checks a checkbox for a given selection, the path string is added to the string array/linked list, and removed when the box is unchecked… then when the user clicks “create jobfile”, the array/linked list is written out to a file.
Is a linked list the best way to go here, or is there a better choice using the .NET framework?
thanks.
|
|
|
|
|
I found this artical and it's been a great help. Only thing is I need to set dWord values greater than 2,147,483,647! I am sure that somebody has found a way around this.
Here is my code:
RegistryKey regKey = Registry.LocalMachine.CreateSubKey(@"SYSTEM\CurrentControlSet\Services\nsunicast\Parameters\Virtual Roots\/"+eId);
regKey.SetValue("MaxBandwidth", 4294967295); // if I change this to below the number above it will set as a dWord all day long.
Any examples, or ideas would rock.
Thanks,
Bill K.
|
|
|
|
|
DWORD = UInt32; //all day long (what ever you meant be that)
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|