|
trbo,
What is the situation that requires moving the files into different locations after install is complete? You have enough control building an MSI to control even dynamic folder locations as long as you have a standard referential point of those folders.
In my one deployment we are installing all of the remoting files and some model files into various directories. I created custom folders driven off of the [TARGETDIR] location. When the user changes TARGETDIR (install path screen) it automatically changes my custom folders as well.
Explain further, I may be able to help you.
This signature left intentionally blank
|
|
|
|
|
Thanks for the help. My Application lays base files and executables and a number of other working files that the user will use in seperate working folders. There are also files that need to copied\moved to server locations to interact with other server applications (I have no idea where these are installed and in most cases they are on different boxes to where my application is being installed.) I have specified that the user should only copy the files not cut them as this initiates the repair install. However in many cases they still cut them and many support calls are logged about this.
I have followed up on the Orca option and have this working. Thanks a million. It is actually very simple. Once you have Orca installed all you need to do is open the MSI file using Orca and add a new property to the Property Table. The property to add is DISABLEADVTSHORTCUTS with a value of 1.
|
|
|
|
|
I'm making some asynchronous calls using Delegate.BeginInvoke. I wanted to know the naughtiness of a fire-and-forget in this situation -- do I really need to call .EndInvoke? It seems Don Box and others say no, while I've read on some other .NET blogs cautions that the framework might leak resources without a .EndInvoke call.
Any thoughts on this?
Also, I would like to get some thoughts on the following code snippet...it appears that using the new anonymous methods in .NET 2 eases the use of .EndInvoke, for example
void OneNiceCleanFunction()
{
ThreadStart lengthyDelegate = delegate
{
DoLengthyFoo();
};
AsyncCallback callbackDelegate = delegate
{
FooAfterLengthy();
lengthyDelegate.EndInvoke();
};
lengthyDelegate.BeginInvoke(callbackDelegate);
}
Any thoughts on how well this code would perform/what overhead the compiler will generate for me? If the above code is acceptable, I imagine it will make the coding of .EndInvoke a lot easier without declaring a bunch of extra fields and methods in the class.
Judah Himango
|
|
|
|
|
|
That's a very good read. He suggests pretty strongly that we should always use EndInvoke... Oddly enough, if you look in the comments to that post, it turns out you don't need to call .EndInvoke on any Sys.Win.Forms.Control classes as it doesn't follow the BeginXXX/EndXXX model the same as delegates.
Judah Himango
|
|
|
|
|
You call EndInvoke when you want the return value of the method (if applicable), or simply to block until the method is done (perhaps you wanted to perform some additional operations while asynronously executing a particular method, but now you want to wait).
Use anonymous methods like that should not be taken lightly. There is a lot of code generated with an automatic naming convention that could change from compile to compile (depending on how your source is modified). Take a look at the article, Create Elegant Code with Anonymous Methods, Iterators, and Partial Classes[^], for more information on how anonymous methods are compiled to type metadata and IL instructions.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
What would be the best way to get a list of installed applications on a local PC? The program I'm working on is to run at startup, gather some PC info, and then insert it into a SSE table.
|
|
|
|
|
leifm wrote:
What would be the best way to get a list of installed applications on a local PC?
There are commercial applications that can provide this type of application so I am sure there are more ways than what I will suggest in this thread however I would first start by looking at the hive of HKEY_LOCAL_MACHINE\SOFTWARE in the registry as this will give you a list of applications installed.
- Nick Parker My Blog | My Articles
|
|
|
|
|
Look in the HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall registry key. You can also use the System.Management classes to get a list of Windows Installer products (only those installed using a Windows Installer package, like Office, VS.NET, Adobe Products (some), etc.) using the Win32_Product CIMv2 class.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I have a datagrid that all of its columns are BoolColumnStyle and its DataSource is a table with no relations. I relate this DG with a counter, when I mark true or false in each DataGridCell the counter adds or subtracts (respectively) a certain number. Also I relate a TreeView with this DataGrid that the previous counter works for each TreeNode under the TopNode in this DataGrid. I use this code to make my datagrid to respond to one click :
<Font face="Courier New" size=2>private void dataGrid1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
DataGrid.HitTestInfo hti = this.dataGrid1.HitTest(e.X, e.Y);
try
{
if( hti.Type = = DataGrid.HitTestType.Cell )
{
int r = (int)hti.Row;
int c = (int)hti.Column;
DataRow dr = table.Rows[r];
DataColumn dc = table.Columns[c];
this.dataGrid1[r,c] = !(bool) this.dataGrid1[r,c];
}
}
catch(Exception ex )
{
MessageBox.Show(ex.ToString());
}
} </font>
I have the following problems :
1. The following message appears. I do not know what is the ListManeger or in other words, I do not understand what is the problem.
The ListManeger’s position must be equal to the rowNum.
Parameter name: rowNum Do you want to correct the value?
2. The DataGrid responds to clicks even when there is no TreeNodes are selected. I want the DataGrid to respond to clicks only when any TreeNode under the TopNode is selected.
3. when the selected TreeNode is changed, I empty the DataGrid by the following code, but the last cell that I add a value to it remains checked :
<Font face="Courier New" size=2>for(int i=0 ; i<table.Rows.Count ; i++)
{
DataRow dr = table.Rows[i];
for(int j=0 ; j<table.Columns.Count; j++)
{
dr[j] = false;
}
}</font>
The problems 1 and 3 disturb my counter.
Please if there is a solution.
Thank you
|
|
|
|
|
The SelectedIndexChanged event for a combobox is fired when a selection in the drop down is clicked (click once to drop down, click again to confirm selection). How do you identify the current selection while the combobox is in drop down mode (prior to second click)? I would like to attach tool tips to the items in the combobox for display prior to a selection being made. How is this done?
|
|
|
|
|
Hi,
I'm having a class which cannot be instanciated but is used throughout the application to indicate the state of various options. Now I was trying to hook this class up to a property-grid, so that the states could be monitored. Unfortunately, the PropertyGrid expects an instance of something for the SelectedObject property. Is there a way you can put there an object with only static properties?
Thanks in advance!
Matthias
If eell I ,nust draw to your atenttion to het fakt that I can splel perfrectly well - i;ts my typeying that sukcs.
(Lounge/David Wulff)
www.emvoid.de
|
|
|
|
|
Because the PropertyGrid is only designed to work on instances the only work around that I am aware of that will work for you would be to write a simple wrapper around the properties you want to watch. This is an example which shows that the PropertyGrid will reflect the changes that occur after the Wrapper has been assigned:
sealed class Fun
{
private Fun(){}
private Fun fun;
public Fun Instance
{
get
{
if(fun == null)
{
lock(typeof(Fun))
{
if(fun == null)
{
fun = new Fun();
}
}
}
return fun;
}
}
public static Color c;
}
public class Wrapper
{
public Wrapper(){}
public Color FunColor
{
get{return Fun.c;}
}
}
private void button_Click(object sender, EventArgs e)
{
Wrapper w = new Wrapper();
g.SelectedObject = w;
Fun.c = Color.Blue;
}
- Nick Parker My Blog | My Articles
|
|
|
|
|
New line is really giving me a tough time...
i have a text box, and it displays the message to another text box.... but when i do Environment.Newline or \r\n, nothing happens....
here is my code
<br />
<br />
using System;<br />
using System.Drawing;<br />
using System.Collections;<br />
using System.ComponentModel;<br />
using System.Windows.Forms;<br />
using System.Data;<br />
using System.Net.Sockets;<br />
using System.Net;<br />
<br />
namespace WindowsApplication1<br />
{<br />
public class Form1 : System.Windows.Forms.Form<br />
{<br />
private System.Windows.Forms.MainMenu mainMenu1;<br />
private System.Windows.Forms.MenuItem menuItem1;<br />
private System.Windows.Forms.MenuItem menuItem2;<br />
private System.Windows.Forms.TextBox textBox1;<br />
private System.Windows.Forms.TextBox textBox2;<br />
private System.Windows.Forms.TextBox textBox3;<br />
private System.Windows.Forms.Label label2;<br />
private System.Windows.Forms.Label label3;<br />
private System.Windows.Forms.Label label4;<br />
private System.Windows.Forms.Button button1;<br />
private System.ComponentModel.Container components = null;<br />
<br />
public Form1()<br />
{<br />
InitializeComponent();<br />
<br />
}<br />
<br />
#region Disposing<br />
protected override void Dispose( bool disposing )<br />
{<br />
if( disposing )<br />
{<br />
if (components != null) <br />
{<br />
components.Dispose();<br />
}<br />
}<br />
base.Dispose( disposing );<br />
}<br />
#endregion<br />
<br />
#region Windows Form Designer generated code<br />
private void InitializeComponent()<br />
{<br />
this.mainMenu1 = new System.Windows.Forms.MainMenu();<br />
this.menuItem1 = new System.Windows.Forms.MenuItem();<br />
this.menuItem2 = new System.Windows.Forms.MenuItem();<br />
this.textBox1 = new System.Windows.Forms.TextBox();<br />
this.textBox2 = new System.Windows.Forms.TextBox();<br />
this.textBox3 = new System.Windows.Forms.TextBox();<br />
this.label2 = new System.Windows.Forms.Label();<br />
this.label3 = new System.Windows.Forms.Label();<br />
this.label4 = new System.Windows.Forms.Label();<br />
this.button1 = new System.Windows.Forms.Button();<br />
this.SuspendLayout();<br />
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {<br />
this.menuItem1});<br />
this.menuItem1.Index = 0;<br />
this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {<br />
this.menuItem2});<br />
this.menuItem1.Text = "File";<br />
this.menuItem2.Index = 0;<br />
this.menuItem2.Text = "Quit";<br />
this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click);<br />
this.textBox1.AutoSize = false;<br />
this.textBox1.BackColor = System.Drawing.SystemColors.WindowText;<br />
this.textBox1.ForeColor = System.Drawing.Color.Honeydew;<br />
this.textBox1.Location = new System.Drawing.Point(16, 24);<br />
this.textBox1.Name = "textBox1";<br />
this.textBox1.ReadOnly = true;<br />
this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;<br />
this.textBox1.Size = new System.Drawing.Size(328, 128);<br />
this.textBox1.TabIndex = 0;<br />
this.textBox1.Text = "";<br />
this.textBox2.AutoSize = false;<br />
this.textBox2.BackColor = System.Drawing.SystemColors.WindowText;<br />
this.textBox2.ForeColor = System.Drawing.Color.MintCream;<br />
this.textBox2.Location = new System.Drawing.Point(384, 24);<br />
this.textBox2.Name = "textBox2";<br />
this.textBox2.ReadOnly = true;<br />
this.textBox2.Size = new System.Drawing.Size(80, 128);<br />
this.textBox2.TabIndex = 1;<br />
this.textBox2.Text = "";<br />
this.textBox3.AcceptsTab = true;<br />
this.textBox3.AutoSize = false;<br />
this.textBox3.BackColor = System.Drawing.SystemColors.WindowFrame;<br />
this.textBox3.ForeColor = System.Drawing.Color.White;<br />
this.textBox3.Location = new System.Drawing.Point(16, 184);<br />
this.textBox3.Name = "textBox3";<br />
this.textBox3.Size = new System.Drawing.Size(384, 40);<br />
this.textBox3.TabIndex = 2;<br />
this.textBox3.Text = "";<br />
this.textBox3.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox3_KeyPressed);<br />
this.textBox3.TextChanged += new System.EventHandler(this.textBox3_TextChanged);<br />
this.label2.Font = new System.Drawing.Font("Eurostile", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));<br />
this.label2.ForeColor = System.Drawing.Color.Lime;<br />
this.label2.Location = new System.Drawing.Point(16, 8);<br />
this.label2.Name = "label2";<br />
this.label2.Size = new System.Drawing.Size(136, 16);<br />
this.label2.TabIndex = 4;<br />
this.label2.Text = "Message Display";<br />
this.label3.BackColor = System.Drawing.Color.Black;<br />
this.label3.Font = new System.Drawing.Font("Eurostile", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));<br />
this.label3.ForeColor = System.Drawing.Color.Lime;<br />
this.label3.Location = new System.Drawing.Point(16, 168);<br />
this.label3.Name = "label3";<br />
this.label3.Size = new System.Drawing.Size(128, 16);<br />
this.label3.TabIndex = 5;<br />
this.label3.Text = "Current Message";<br />
this.label4.Font = new System.Drawing.Font("Eurostile", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));<br />
this.label4.ForeColor = System.Drawing.Color.Lime;<br />
this.label4.Location = new System.Drawing.Point(376, 8);<br />
this.label4.Name = "label4";<br />
this.label4.Size = new System.Drawing.Size(104, 16);<br />
this.label4.TabIndex = 6;<br />
this.label4.Text = "Clients Online";<br />
this.label4.Click += new System.EventHandler(this.label4_Click);<br />
this.button1.BackColor = System.Drawing.Color.Black;<br />
this.button1.Font = new System.Drawing.Font("Eurostile", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));<br />
this.button1.ForeColor = System.Drawing.Color.Lime;<br />
this.button1.Location = new System.Drawing.Point(264, 240);<br />
this.button1.Name = "button1";<br />
this.button1.Size = new System.Drawing.Size(88, 24);<br />
this.button1.TabIndex = 7;<br />
this.button1.Text = "Connect";<br />
this.button1.Click += new System.EventHandler(this.button1_Click);<br />
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);<br />
this.BackColor = System.Drawing.SystemColors.ControlText;<br />
this.ClientSize = new System.Drawing.Size(488, 273);<br />
this.Controls.Add(this.button1);<br />
this.Controls.Add(this.label4);<br />
this.Controls.Add(this.label3);<br />
this.Controls.Add(this.label2);<br />
this.Controls.Add(this.textBox3);<br />
this.Controls.Add(this.textBox2);<br />
this.Controls.Add(this.textBox1);<br />
this.Menu = this.mainMenu1;<br />
this.Name = "Form1";<br />
this.Text = "ChatteX v1.0";<br />
this.ResumeLayout(false);<br />
<br />
}<br />
#endregion<br />
<br />
#region Client Variables...<br />
byte[] m_dataBuffer = new byte [10];<br />
IAsyncResult m_result;<br />
public AsyncCallback m_pfnCallBack ;<br />
public Socket m_clientSocket;<br />
#endregion<br />
<br />
#region AppMain()<br />
[STAThread]<br />
static void Main() <br />
{<br />
Application.Run(new Form1());<br />
}<br />
#endregion<br />
<br />
#region Program Functions<br />
public void SetText(TextBox m, TextBox d)<br />
{<br />
<br />
string buffer =Environment.NewLine;<br />
<br />
buffer =m.Text+Environment.NewLine;<br />
d.Text += buffer;<br />
m.Text ="";<br />
}<br />
<br />
<br />
public void WaitForData()<br />
{<br />
try<br />
{<br />
if ( m_pfnCallBack == null ) <br />
{<br />
m_pfnCallBack = new AsyncCallback (OnDataReceived);<br />
}<br />
SocketPacket theSocPkt = new SocketPacket ();<br />
theSocPkt.thisSocket = m_clientSocket;<br />
m_result = m_clientSocket.BeginReceive (theSocPkt.dataBuffer,<br />
0, theSocPkt.dataBuffer.Length,<br />
SocketFlags.None, <br />
m_pfnCallBack, <br />
theSocPkt);<br />
}<br />
catch(SocketException se)<br />
{<br />
MessageBox.Show (se.Message );<br />
}<br />
<br />
}<br />
public class SocketPacket<br />
{<br />
public System.Net.Sockets.Socket thisSocket;<br />
public byte[] dataBuffer = new byte[1];<br />
}<br />
<br />
public void OnDataReceived(IAsyncResult asyn)<br />
{<br />
try<br />
{<br />
SocketPacket theSockId = (SocketPacket)asyn.AsyncState ;<br />
int iRx = theSockId.thisSocket.EndReceive (asyn);<br />
char[] chars = new char[iRx + 1];<br />
System.Text.Decoder d = System.Text.Encoding.UTF8.GetDecoder();<br />
int charLen = d.GetChars(theSockId.dataBuffer, 0, iRx, chars, 0);<br />
System.String szData = new System.String(chars);<br />
textBox1.Text += szData;<br />
WaitForData();<br />
}<br />
catch (ObjectDisposedException )<br />
{<br />
System.Diagnostics.Debugger.Log(0,"1","\nOnDataReceived: Socket has been closed\n");<br />
}<br />
catch(SocketException se)<br />
{<br />
MessageBox.Show (se.Message );<br />
}<br />
} <br />
<br />
<br />
#endregion<br />
<br />
#region Event Handlers<br />
private void menuItem2_Click(object sender, System.EventArgs e)<br />
{<br />
if(MessageBox.Show("Are you sure you want to quit?","Exit Code:101",<br />
MessageBoxButtons.OKCancel,MessageBoxIcon.Warning)== DialogResult.OK)<br />
{<br />
Application.Exit();<br />
}<br />
}<br />
<br />
private void textBox3_TextChanged(object sender, System.EventArgs e)<br />
{<br />
} <br />
<br />
private void textBox3_KeyPressed(object sender, KeyPressEventArgs e)<br />
{<br />
if(e.KeyChar == (char)13)<br />
{ <br />
SetText(textBox3,textBox1);<br />
}<br />
}<br />
private void label4_Click(object sender, System.EventArgs e)<br />
{<br />
<br />
}<br />
<br />
<br />
<br />
private void button1_Click(object sender, System.EventArgs e)<br />
{<br />
textBox1.Text +="Connecting to server....\r\n";<br />
<br />
try<br />
{<br />
m_clientSocket = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp );<br />
IPAddress ip = IPAddress.Parse("65.96.57.169");<br />
int iPortNo = 2486;<br />
IPEndPoint ipEnd = new IPEndPoint (ip,iPortNo);<br />
m_clientSocket.Connect ( ipEnd );<br />
<br />
if(m_clientSocket.Connected) <br />
{<br />
textBox1.Text+="Connection Aquired...\r\n";<br />
WaitForData();<br />
}<br />
}<br />
catch(SocketException se)<br />
{<br />
MessageBox.Show (se.ToString(),"Server is down",MessageBoxButtons.OKCancel);<br />
} <br />
#endregion <br />
} <br />
}<br />
<br />
<br />
} <br />
<br />
<br />
<br />
|
|
|
|
|
|
wow im a noob thanks lol >.<
|
|
|
|
|
Hello all,
I am using code:
objMyConn=this.DB_Connection();
objMyConn.Open();
objCmd = new OleDbCommand(str_SQL, objMyConn);
objCmd.ExecuteNonQuery();
objMyConn.Close();
When I try using the same SQL in Oracle, it takes 455ms, and if I try running it from .net app, it takes 9-15 min. Should I not use Dynamic SQL for this?
Thanks
|
|
|
|
|
You should never use "dynamic SQL". You use parameterized queries, or risk opening a hole in your code. You have to check for SQL inject attacks, as well as encode your quotes (both single and double) in the parameter values youself. This is why the OleDbCommand.Parameters collection property and the OleDbParameter class exist. Read about them in the .NET Framework SDK. Why it takes so long really depends on a number of factors that your code above just doesn't provide.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi...
I want to write to a Registry key...
I tried this...
try
{
string path = Environment.CurrentDirectory.ToString();
Microsoft.Win32.Registry.LocalMachine.OpenSubKey("software").CreateSubKey("SK").CreateSubKey("Info").SetValue("Path", path);
}
catch
{
}
But it throws an UnauthoriziedAccessException that says 'Cannot write to the registry key.'
Can anyone help me?
QzRz
|
|
|
|
|
|
hey - I'm hoping someone on the forum can help me with this. It's a fairly mundane problem, but I can't seem to get around it.
I cannot send an email from an ASP.net application. I get the 0x80040220 error - basically, I don't have permission to send email. Exactly the same code run from a Win32 app works perfectly. A check at MSDN comes up with a slew of solutions, ranging from the vague ("run your web app with correct permissions") to the amazing (download Exchange Server SP3, weighing in at 160+ Megs).
I'm developing a small open source app that needs to send email from an ASP page - I'm looking for a clean and elegant solution to this problem - something I can set in my code without having to ask ppl who use my app to monkey around with their IIS permissions or download a 160 meg "patch".
Any ideas? I'd really appreciate them. After spending weeks banging together my application, it's pretty annoying that it fails on something as trivial as not being able to send out a simple email.
|
|
|
|
|
|
Hi, guys.I am developing an application running in PocketPC. My question is how I can operate the registry of Windows CE. Are there some classes which can be used directly? Or I have to use unmaged code to invoke some API to do that? Could you please to recommend some resources to introduce relevant contents?
Thanks a lot
vigorous
|
|
|
|
|
This question really belongs in the embedded/mobile section however it is easy enough to just answer it here. The .NET Compact Framework does not come with a supported Registry class as is available under the .NET Framework. This said, you will need to P/Invoke RegOpenKeyEx , RegQueryValue , and ExRegCloseKey to have access to the registry.
- Nick Parker My Blog | My Articles
|
|
|
|
|
I have a datagrid that all of its columns are BoolColumnStyle and its DataSource is a table with no relations. I relate this DG with a counter, when I mark true or false in each DataGridCell the counter adds or subtracts (respectively) a certain number. Also I relate a TreeView with this DataGrid that the previous counter works for each TreeNode under the TopNode in this DataGrid. I use this code to make my datagrid to respond to one click :
private void dataGrid1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
DataGrid.HitTestInfo hti = this.dataGrid1.HitTest(e.X, e.Y);
try
{
if( hti.Type = = DataGrid.HitTestType.Cell )
{
int r = (int)hti.Row;
int c = (int)hti.Column;
DataRow dr = table.Rows[r];
DataColumn dc = table.Columns[c];
this.dataGrid1[r,c] = !(bool) this.dataGrid1[r,c];
}
}
catch(Exception ex )
{
MessageBox.Show(ex.ToString());
}
} // dataGrid1_MouseUp
I have the following problems :
1. The following message appears. I do not know what is the ListManeger or in other words, I do not understand what is the problem.
2. The DataGrid responds to clicks even when there is no TreeNodes are selected. I want the DataGrid to respond to clicks only when any TreeNode under the TopNode is selected.
3. when the selected TreeNode is changed, I empty the DataGrid by the following code, but the last cell that I add a value to it remains checked :
for(int i=0 ; i
|
|
|
|
|