|
How can i check in Run Time if in current machine that execute my application (exe file) has an active microphone ?
|
|
|
|
|
You can't detect if a microphone is physically connected or not. What you could do is monitor the sound levels and see if there is something coming in on the input.
Simon
|
|
|
|
|
Good Afternoon All
I dont know if am asking this in a Correct way Purdon me if i dont. I have a Help file that gets opened with "Windows Winhlp32 Stub. i need to Call this in C#, in my Menu, when a User Clicks Help it should Show this Menu. I have attached the Examples. How can i call this Files in C#.
http://www.vbforums.com/attachment.php?attachmentid=67180&stc=1&d=1224678042[^]"> Example
Thank you
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
I have a foreach loop i want to write on one line of code. does anyone know a "one-Liner" for this. This must be fairly common but i havent found any.
List<animals> animals = (Fill list somehow...)
List<int> teeths = new List<int>();
foreach(Animal a in animals)
{
teeths.Add(a.TeethCount);
}
//i want Something like this:
List<int> teeths = animals.ExtractPropertyList(delegate(Animal ani){"return all Teeths"});
Anyone?
|
|
|
|
|
List<int> teeths = animals.ConvertAll<int>(delegate(Animal animal) { return animal.TeethCount; });
|
|
|
|
|
good stuff.
Exactly what i wanted.
|
|
|
|
|
If you use .Net 3.5 you can also do a LINQ query like this:
List<int> teeths = (from animal in animals select animal.TeethCount).ToList();
or (the behavior is the same):
List<int> teeths = animals.Select(animal => animal.TeethCount).ToList();
modified on Wednesday, October 22, 2008 8:21 AM
|
|
|
|
|
Hi all,
I have create data reports for my application.I want print report when user click print button on entry form(Not on report viewer) rather than it's shown through report viewer.If possible please send any sample code for that.
Thanks.
|
|
|
|
|
Hi,
I am executing a PowerPoint slide show file (.pps) from my C# source code using:
System.Diagnostics.Process extProcess = System.Diagnostics.Process.Start("xdsfr.pps");
extProcess.WaitForExit();
The problem here is my source code immediately continues to execute and does wait for PowerPoint to exit.
It seems that somehow extProcess receives "Exit" event from PowerPoint (although PowerPoint is still operating.) Because when I check for "HasExited" property of extProcess while debugging I can see it as "true".
Googling about the issue gave me nothing. If you guys can give me a hint, it is appreciated.
Thank you for your time,
Regards,
Always keep the Murphy Rules in mind!
|
|
|
|
|
I guess that when new process is started it calls another executable file and passes xdsfr.pps as an argument to it and the process itself exits so that's why your code doesn't stop. If my assumption is correct then you can try to find out which executable is being called and call it yourself or you can try if this helps: Using WMI to monitor process creation, deletion and modification in .NET[^]
|
|
|
|
|
I suspect its because you are not really executing xdsfr.pps, under the hood you are executing POWERPNT.EXE and passing the file name to it. Try executing POWERPNT.EXE and passing the file name as a parameter.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Thanx for the suggestion Bob,
Tried:
extProcess = System.Diagnostics.Process.Start("POWERPNT.EXE", filename);
and result is the same.
I will go with Giorgi's suggestion and see if it helps.
Thank you both guys.
Always keep the Murphy Rules in mind!
modified on Wednesday, October 22, 2008 6:48 AM
|
|
|
|
|
You need to use the proper command line arguments: http://pptfaq.com/FAQ00528.htm[^]
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my Blog
|
|
|
|
|
Thomas, thank you for your suggestion, I have tried the command line arguments but still my code does not wait for PowerPoint to exit.
Giorgi, I have modified and used the code that you have linked. But the Process that executes the pps file exits in no time, I could not catch any of the events through POWERPNT.exe when I added to ProcessWatcher.
I also tried to watch my own executable but it did not fire events too. I am not sure if I did all correctly I will keep trying for while.
Funny (or should I say sad for me) I am using the same method with Visio, but the code executes just as I have expected. When I call "xdsfr.vsd" (which I have exported in previous operations) my executable hangs up operation and waits until Visio exits...
Always keep the Murphy Rules in mind!
modified on Wednesday, October 22, 2008 10:18 AM
|
|
|
|
|
I have found the error.
And it is not related to the code that I have given.
For anyone who encounters the same mistake, here is my experience:
Since I use the POWERPNT.EXE in my previous operations, the Process for this executable is not properly disposed thats why I can still see the POWERPNT.EXE in my TaskManager/Processes tab. (This happens before the code in above posts is executed.)
Thats why when my code executes it seems that it cannot attach itself to POWERPNT.EXE.
When I managed to dispose POWERPNT.EXE process before executing the code, everything worked just fine.
Thanks for help guys,
Regards
Always keep the Murphy Rules in mind!
|
|
|
|
|
hi,
I am trying to autoformat an Excel (.xls) file and then import it into Sql server 2000 table using C# in Asp.net. But when i try to autoformat the excel file i get the exception "Attempted to read or write protected memory. This is often an indication that other memory is corrupt." Someone please help me to solve this problem
Here is the code.
sing System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Data.OleDb;
using System.Data.Odbc;
using System.Text;
using Microsoft.Office.Interop.Excel;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection Cn = new SqlConnection("server=321.14.45.137; database= NitDB; User ID=sa; Password= g");
SqlCommand Cm = new SqlCommand("Select * from ExcelFile", Cn);
Cn.Open();
SqlDataReader St = Cm.ExecuteReader();
gdExcelFile.DataSource = St;
gdExcelFile.DataBind();
St.Close();
Cn.Close();
}
public static void PrintProgressBar()
{
StringBuilder sb = new StringBuilder();
sb.Append("<div id='updiv' style='Font-weight:bold;font-size:11pt;Left:320px;COLOR:black;font-family:verdana;Position:absolute;Top:140px;Text-Align:center;'>");
sb.Append(" <script> var up_div=document.getElementById('updiv');up_div.innerText='';</script>");
sb.Append("<script language=javascript>");
sb.Append("var dts=0; var dtmax=10;");
sb.Append("function ShowWait(){var output;output='Reading data from excel...PLEASE WAIT!';dts++;if(dts>=dtmax)dts=1;");
sb.Append("for(var x=0;x < dts; x++){output+='';}up_div.innerText=output;up_div.style.color='red';}");
sb.Append("function StartShowWait(){up_div.style.visibility='visible';ShowWait();window.setInterval('ShowWait()',100);}");
sb.Append("StartShowWait();</script>");
HttpContext.Current.Response.Write(sb.ToString());
HttpContext.Current.Response.Flush();
}
public static void ClearProgressBar()
{
StringBuilder sbc = new StringBuilder();
sbc.Append("<script language='javascript'>");
sbc.Append("alert('Data exported successfully');");
sbc.Append("up_div.style.visibility='hidden';");
sbc.Append("history.go(-1)");
sbc.Append("</script>");
HttpContext.Current.Response.Write(sbc);
}
protected void btnExport_Click(object sender, EventArgs e)
{
PrintProgressBar();
{
OdbcConnection connection;
SqlBulkCopy bulkCopy;
string ConnectionString = @"server=23.23.44.136;database= NitDB; User ID= fg; Password=g";
string connstr = @"Driver={Microsoft Excel Driver (*.xls)};DriverId=790;Dbq=" + fyle.Value;
using (connection = new OdbcConnection(connstr))
{
string[] temp;
string fn1;
fn1 = System.IO.Path.GetFileName(fyle.PostedFile.FileName); \\ fyle is the Html File upload control
temp = fn1.Split('.');
object missing = System.Reflection.Missing.Value;
Microsoft.Office.Interop.Excel.Application excel = default(Microsoft.Office.Interop.Excel.Application);
Microsoft.Office.Interop.Excel.Workbook wb = default(Microsoft.Office.Interop.Excel.Workbook);
excel = new Microsoft.Office.Interop.Excel.Application();
// I get the exception at the below statement.
wb = excel.Workbooks.Open(fn1, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing);
excel.Visible = true;
//wb.Activate();
excel.Cells.Select();
excel.Columns.AutoFit();
excel.Rows.AutoFit();
OdbcCommand command = new OdbcCommand("Select * FROM [" + temp[0].ToString() + "$]", connection);
connection.Open();
using (OdbcDataReader dr = command.ExecuteReader())
{
using (bulkCopy = new SqlBulkCopy(ConnectionString))
{
bulkCopy.DestinationTableName = "ImportedExcel";
bulkCopy.WriteToServer(dr);
}
dr.Close();
}
}
bulkCopy.Close();
connection.Close();
}
ClearProgressBar();
}
}
Nitin Raj Bidkikar
|
|
|
|
|
This code works fine for me.
object missing = System.Reflection.Missing.Value;
Microsoft.Office.Interop.Excel.Application excel = default(Microsoft.Office.Interop.Excel.Application);
Microsoft.Office.Interop.Excel.Workbook wb = default(Microsoft.Office.Interop.Excel.Workbook);
excel = new Microsoft.Office.Interop.Excel.Application();
wb = excel.Workbooks.Open(@"c:\test.xls", missing, missing,
missing, missing, missing, missing, missing, missing, missing,
missing, missing, missing, missing, missing);
excel.Visible = true;
Check that the file you are trying to open definitely exists. Try testing out just this block of code in a separate test application.
[BTW: If you use <pre> </pre> tags around your code it makes it easier to read.]
Simon
|
|
|
|
|
hello
my Question is about Multi Threads On Multi Processor platforms.
how to be Implement Multi Threads in C# on Multi Processors that the Processors have multi core (e.g 4 core for per Processors).
Distribute of Thread Between core done by OS or done by appliction programer ????
|
|
|
|
|
The distribution is done by the Operating System.
If you want to implement extra threads, then check out the BackgroundWorker-component. There are multiple articles on the CodeProject that explain both the BackgroundWorker and how to create threads from code.
|
|
|
|
|
|
What Operating System does you main server use?
|
|
|
|
|
Windows Server 2003
Thankq
|
|
|
|
|
Would this one work for you?
http://www.codeproject.com/KB/IP/ListNetworkComputers.aspx
|
|
|
|
|
The Link which u have send is the desktop Application.I have tryed that also but it could not help me out.What i want is for Web Application....
Plz Its Urgent for me.....
ThankQ
|
|
|
|
|
Do you want the list of the names of the computers attached to your local network?
Or do you want to know the name of the computer over the internet?
--Edit--
The word "Urgent" is ignored here. Everyone is in a rush these days
|
|
|
|