|
As Sascha noted, it is essentially impossible in the general case.
"Fairy tales do not tell children the dragons exist. Children already know that dragons exist. Fairy tales tell children the dragons can be killed."
- G.K. Chesterton
|
|
|
|
|
How is it impossible?
Ths same sofotawre can run on a motherboard whether it is Linx, Windows Vista, 7, 8 or 10, etc. If hardware is unchanging, softwre must know to
modified 27-Mar-16 4:53am.
|
|
|
|
|
regerteast wrote: Ths same sofotawre can run on a motherboard whether it is Linx, Windows Vista, 7, 8 or 10, etc. If hardware is unchanging, softwre must know to interact. The software does not care about the details of the motherboard. All non-standard hardware comes with software that knows how to talk to that hardware, aptly called "drivers".
regerteast wrote: ON SOFTWARE Software can only process signals from hardware. It's not magic.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Eddy Vluggen wrote: The software does not care about the details of the motherboard. All non-standard hardware comes with software that knows how to talk to that hardware, aptly called "drivers".
But even on completly standard hardware I can widnows view the temperature of CPU, etc. How is the code to see it?
|
|
|
|
|
There is no such thing as "completely standard hardware" in the PC world: all PC's are assembled using a huge number of possible components. Your example is spectacularly wrong: there are Intel and AMD versions of the "basic" processor, each of which has a large number of different processors in it's range. And to read the processor temperature is different in each family!
So the OS has a API which works out which processor it is, and reads the temperature appropriately - but it looks like a simple WMI request to your application (most of the time, sometimes the motherboard design makes it unavailable) because the OS "hides" the hardware from your application. That is part of what drivers are for: to interface between the hardware (or a virtualisation of the hardware - don't ask, just don't) and the OS so that the hardware maker can communicate in a way that the OS can understand, and interpret for the applications.
It's a bit like your car: it has a fuel gauge, but you have no idea how that gauge actually works or how many litres of fuel it is showing - and you don't need to know as long as you can glance at the dashboard and see you have 1/3 tank left.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
OriginalGriff wrote: So the OS has a API which works out which processor it is, and reads the temperature appropriately - but it looks like a simple WMI request to your application (most of the time, sometimes the motherboard design makes it unavailable) because the OS "hides" the hardware from your application. That is part of what drivers are for: to interface between the hardware (or a virtualisation of the hardware - don't ask, just don't) and the OS
So software if sits on top of the OS enabled through drivers and underlying to access but all is encapsulated in the OS so to software it is the same so one code to examine physical component of the motherboard the same regardless of individual hardware
so to read temperature of component onw libary is good
|
|
|
|
|
That's the whole idea - the application doesn't get to look at the hardware, any more than you have to physically look at the sensor in your fuel tank! The OS and the drivers each provide a layer of abstraction that prevent your app getting anywhere near it.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
regerteast wrote: But even on completly standard hardware I can widnows view the temperature of CPU, etc. Completely standard hardware does not have to include the sensor.
If it is, it will be conforming to a standard. If Windows supports the sensor, then you can query it using the Sensor API introduced with Win7.
regerteast wrote: How is the code to see it? Sensor API (Windows)[^]
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
|
You're welcome
|
|
|
|
|
I've worked with a format called Gencad for this. The Gencad file specification is available somewhere on the Internet; once you get it, you need to read the CAD file based on this spec, and then render the different PCB elements on the screen using GDI kind of commands.
Had developed a Gencad viewer, and this is property of one of my earlier employers.
|
|
|
|
|
i have this code but it's giving error(the name ZipFile doesnot exist in the current content) because of framework 4.5.1
using System;
using System.IO.Compression;
{
const string ZIP_FILE = @"C:\temp\test\temp.zip";
const string ZIP_FOLDER = @"C:\temp\test\";
using (ZipArchive archive = ZipFile.Open(ZIP_FILE, ZipArchiveMode.Read))
{
foreach (ZipArchiveEntry entry in archive.Entries)
{
entry.ExtractToFile(ZIP_FOLDER + entry.Name);
}
}
}
|
|
|
|
|
|
Import below namespace
add a reference to the System.IO.Compression.FileSystem assembly in your project, it will resolve you issue,
basically 'Compression' namespace is introduced in framework 4.5 and above
Find More .Net development tips at : .NET Tips
The only reason people get lost in thought is because it's unfamiliar territory.
|
|
|
|
|
In crystal reports i have used xml file to display the data. the fields are displaying but data is not displayed and parameter filter is also not working.
Below is the code:
private void _Toolbar1_Button13_Click(object sender, EventArgs e)
{
count = 0;
DataSet ds = new DataSet();
DataTable dt = new DataTable();
SiimsReports.ReportForms.FormReportDisplay frmRpt = new FormReportDisplay();
SiimsReports.Reports.ServiceRpt objservice = new SIIMS.SiimsReports.Reports.ServiceRpt();
foreach (string cust in lstCustName .SelectedItems )
{
foreach (string reg in lstRegion.SelectedItems )
{
{
foreach (string sys in lstSysName.SelectedItems )
{
string strsql = "select custname,regname ,location ,sysnames ,sysmake ,servicedate ,district,"
+ " (pendingpoints+'.' +remarks) pendingpoints,batteryreplacedon,servicetype from Leo_ServiceOrder where custname='" + cust + "' "
+ " and regname='" + reg + "' and sysnames='" + sys + "' and servicedate between '" + dtpFromDt.Value.ToString("yyyy-MM-dd") + "' and "
+ "'" + dtpToDt.Value.ToString("yyyy-MM-dd") + "'";
dt = objSO.ServiceReport(strsql);
if (dt.Rows.Count > 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
objSO.custname = dt.Rows[i]["custname"].ToString();
objSO.regname = dt.Rows[i]["regname"].ToString();
objSO.location = dt.Rows[i]["location"].ToString();
objSO.sysnames = dt.Rows[i]["sysnames"].ToString();
objSO.sysmake = dt.Rows[i]["sysmake"].ToString();
objSO.pendingpoints = dt.Rows[i]["pendingpoints"].ToString();
objSO.serviceorderdate = dt.Rows[i]["servicedate"].ToString();
objSO.district = dt.Rows[i]["district"].ToString();
objSO.batteryreplaced = dt.Rows[i]["batteryreplacedon"].ToString();
objSO.servicetype = dt.Rows[i]["servicetype"].ToString();
objSO.InsertServiceRpt();
}
}
}
}
}
}
string strqry = "select * from Leo_TempServiceOrder";
ds = objSO.getServiceReport(strqry);
string spath = Application.StartupPath;
string newpath = "C:\\Program Files\\Default Company Name\\LeoSetup\\";
newpath = newpath + "SiimsReports\\Reports\\ServiceReports.rpt";
CrystalDecisions.CrystalReports.Engine.ReportDocument myrpt = new ReportDocument();
myrpt.Load(newpath);
myrpt.SetDatabaseLogon("sa", "prerana123", @"DISHU-PC\SQLEXPRESS", "LeoNew");
myrpt.SetDataSource(ds);
frmRpt.crViewer.ReportSource = myrpt;
frmRpt.Show();
Please help me in resolving the above issue.
Thanks
|
|
|
|
|
First off, don't do it like that.
Do not concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Use Parametrized queries instead.
Fixing that will very likely fix your other problem as well (and make you code more readable)
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
|
I have created thread list and started two thread
but I could not able to listbox even I had handled the cross thread issue. now once I run the app, I could not get the cross thread error, but app is hang and form also not displaying.
below is the code form1.cs:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Globalization;
using System.Data.SqlClient;
using System.Threading;
using System.Reflection;
using System.Diagnostics;
using System.Web;
using System.Xml;
using System.Net;
namespace GALAXY_LEAD_SERVER
{
public partial class Form1 : Form
{
static int i = 0;
static int corecamp = 0;
static int cmpnID = 0;
private Thread workerThread = null;
private bool stopProcess = false;
private delegate void UpdateStatusDelegate();
private UpdateStatusDelegate updateStatusDelegate = null;
CRCSMS crcsms = new CRCSMS();
static int serverStatus = 0;
public static string mystatus = "";
static string AppLogFile = "SG_LeadServer";
public static string logPath = Directory.GetCurrentDirectory() + "\\LOGS\\" + DateTime.Now.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture).Replace("/", "");
SqlCommand cmd = new SqlCommand();
GalaxyConfig GC = new GalaxyConfig();
GalaxyLib GL = new GalaxyLib();
LIBVALUE LB = new LIBVALUE();
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
string version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
mystatus = "Load SG Lead Server " + version;
this.updateStatusDelegate = new UpdateStatusDelegate(this.UpdateStatus);
this.BeginInvoke(this.updateStatusDelegate);
this.Text = "SPECTRUM LEAD SERVER " + version;
if (serverStatus == 0)
{
ServerStatustextBox.Text = "Stopped";
Startbutton.Text = "Start";
}
else
{
Startbutton.Text = "Stop";
ServerStatustextBox.Text = "Running";
}
mystatus = "Current Status: " + ServerStatustextBox.Text;
this.BeginInvoke(this.updateStatusDelegate);
}
class FileInfo
{
public int HostId { get; set; }
public string Extension { get; set; }
public string FolderPath { get; set; }
}
private void Startbutton_Click(object sender, EventArgs e)
{
var threads = new List<Thread>();
string[] services = new string[2];
services[0] = 1.ToString();
services[1] = 2.ToString();
if (serverStatus == 0)
{
AppLogFile = "SG_LeadServer";
this.stopProcess = false;
serverStatus = 1;
Startbutton.Text = "Stop";
ServerStatustextBox.Text = "Running";
for (int i = 0; i <= services.Length - 1; i++)
{
var hostID = (int)i;
FileInfo ff = new FileInfo();
var thread = new Thread(HeavyOperation)
{
Name = string.Format("myService{0}", i),
};
thread.Start(new FileInfo
{
HostId = hostID,
});
threads.Add(thread);
mystatus = "Added Thread: " + thread.Name.ToString();
this.BeginInvoke(this.updateStatusDelegate);
threads[i].Join();
mystatus = "Joined Thread: " + thread.Name.ToString();
this.BeginInvoke(this.updateStatusDelegate);
}
}
else if (serverStatus == 1)
{
this.stopProcess = true;
serverStatus = 0;
LoadCampaigns();
Startbutton.Text = "Start";
ServerStatustextBox.Text = "Stopped";
AppLogFile = "SG_LeadServer";
}
mystatus = "Current Status: " + ServerStatustextBox.Text;
this.BeginInvoke(this.updateStatusDelegate);
}
private void timer1_Tick(object sender, EventArgs e)
{
TimeLabel.Text = DateTime.Now.ToString("dd-MM-yyyy hh:mm:ss");
}
private void HeavyOperation(object threadState)
{
for (i = 0; i <= 10; i++)
{
cmpnID = 8;
Thread.Sleep(500);
if (!this.stopProcess)
{
if (serverStatus == 0)
{
mystatus = "Server stopped.contact administrator";
return;
}
LoadCampaigns();
}
else
{
}
if (i > 9) i = 0;
}
}
private void HeavyOperation1()
{
for (i = 0; i <= 10; i++)
{
cmpnID = 10;
Thread.Sleep(500);
if (!this.stopProcess)
{
if (serverStatus == 0)
{
mystatus = "Server stopped.contact administrator";
return;
}
LoadCampaigns();
}
else
{
}
if (i > 9) i = 0;
}
}
private void UpdateStatus()
{
if (listBox1.Items.Count > 500) listBox1.Items.Clear();
this.textBox1.Text = i.ToString();
if (mystatus != "")
{
if(AppLogFile!="SG_LeadServer")
mystatus=LB.campaignName+"("+LB.campaignID+"): "+ mystatus;
this.listBox1.Items.Insert(0, DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss") + " ==> "+ mystatus);
crcsms.writeLogFile(logPath, AppLogFile, mystatus);
}
mystatus = "";
}
private void Form1_FormClosed(object sender, FormClosedEventArgs e)
{
mystatus = "App stop: " + ServerStatustextBox.Text;
this.BeginInvoke(this.updateStatusDelegate);
this.workerThread.Abort();
}
private void LoadCampaigns()
{
if (serverStatus == 1)
{
LB.getCampaignDetails(cmpnID);
AppLogFile = LB.campaignName;
DataTable dt = new DataTable();
dt = LB.getBatchDetails(LB.campaignID);
this.BeginInvoke(this.updateStatusDelegate);
int rowindex = 0;
cmd.Connection = GC.getcon_Galaxy();
this.BeginInvoke(this.updateStatusDelegate);
foreach (DataRow row in dt.Rows)
{
string strBatch = dt.Rows[rowindex][1].ToString();
mystatus = "Found Active Batch for campaign(" + LB.campaignID + ")" + LB.campaignName + ":-" + strBatch;
this.BeginInvoke(this.updateStatusDelegate);
GalaxyLib.getCampaignDetails GL = new GalaxyLib.getCampaignDetails();
GL.updateMasterInsertQueue(LB.campaignID, strBatch,LB.outBoundDBName,LB.leadMasterTableName,LB.leadQueueTableName);
this.BeginInvoke(this.updateStatusDelegate);
rowindex = rowindex + 1;
}
}
else
{
}
}
private void Stop_service1()
{
LB.getCampaignDetails(8);
GalaxyLib.getCampaignDetails GL = new GalaxyLib.getCampaignDetails();
GL.updateDeleteWhileStoppingServer(LB.outBoundDBName, LB.leadMasterTableName, LB.leadQueueTableName);
this.BeginInvoke(this.updateStatusDelegate);
LB.getCampaignDetails(10);
GL.updateDeleteWhileStoppingServer(LB.outBoundDBName, LB.leadMasterTableName, LB.leadQueueTableName);
this.BeginInvoke(this.updateStatusDelegate);
}
}
}
|
|
|
|
|
|
Thanks Homar...Just I need one more help:
below are the steps which I did:
1)created 5 backgroundworkers and it runs parallely.
2)crated one function to write the logs
3)created one public string veriable as "myLogText".
4)called the write log function in each background worker to write the logs
5)passing myLogText string in write log function
6)once run the program, app creates the log files backgroundworkerwise and write the logs but I realised that texts are mismatching..that means one log file created by backgroundworker1 but in text file text content are there from other background worksers also
please help me ...
|
|
|
|
|
Without seeing your code, I can only guess that you're trying to update a single string variable from multiple threads.
Either use a different string variable for each BackgroundWorker, or pass the log messages to the ReportProgress method[^] and update the variable from the ProgressChanged event[^].
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hello there.
Question 1
I am given this proprietary sdk using which I am displaying video. I give this sdk the window handle and it just shows the video. Code resembles the following code
private void LoadVideo(IntPtr picboxWindowHandle)
{
ProprietarySDK obj = new ProprietarySDK();
obj.WindowHandle = picboxWindowHandle;
obj.Play();
}
And this plays the video. Fine.
But the problem is: I can not get the image from PictureBox using both Image and BackgroundImage properties as shown below
Bitmap bmp1 = pictureBox.Image;
Bitmap bmp2 = pictureBox.BackgroundImage;
What am I doing wrong here??
Question 2
Is there any chance I could draw simple string on this same picturebox. I am trying to draw using
Graphics graphics = Graphics.FromHwnd(pictureBox.Handle)
object but unable to do it. It shows absolutely nothing.
Thanks for any input.
|
|
|
|
|
- The video is (sort of) displayed on top of the picturebox, so you can't get the videopicture from the picturebox. All that is used is the windowhandle of the picturebox - you could have used any type of control that exposes a windowhandle, for instance a label or a panel.
You have to check if the ProprietarySDK (obj) exposes some method or property that returns the videopicture, otherwise the only option you have is doing a screencopy (of the picturebox area). - You can draw on top of the picturebox (image) but not on top of the video, again for the same reason as above: the video is displayed on top of the picturebox and thus on top of your drawing.
Peter
|
|
|
|
|
I have a datagrid with records and i wish to generate serial numbers automatically at the last column
My datagrid is given below
<asp:GridView ID="grid" runat="server" AutoGenerateColumns="False"
HeaderStyle-BorderColor="#996633" Width="98%" AllowPaging="True"
BackColor="White" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px"
CellPadding="3" ForeColor="Black"
onpageindexchanging="grid_PageIndexChanging" PageSize="20"
AllowSorting="True" onrowediting="grid_RowEditing"
onrowupdating="grid_RowUpdating">
<AlternatingRowStyle BackColor="#CCCCCC" />
<Columns>
<asp:BoundField HeaderText ="Reg. No"
ControlStyle-Width ="10%" DataField="AdmNo" SortExpression="AdmNo" >
<ControlStyle Width="20%"></ControlStyle>
<ItemStyle Width="10%" />
</asp:BoundField>
<asp:BoundField HeaderText ="Ass(1)"
ControlStyle-Width = "10%" DataField="Ass1" SortExpression="Ass1" >
<ControlStyle Width="15%"></ControlStyle>
<ItemStyle Width="10%" />
</asp:BoundField>
<asp:BoundField HeaderText ="Ass(2)"
ControlStyle-Width = "10%" DataField="Ass2" SortExpression="Ass2" >
<ControlStyle Width="15%"></ControlStyle>
<ItemStyle Width="10%" />
</asp:BoundField>
<asp:BoundField HeaderText ="Test(1)"
ControlStyle-Width = "15%" DataField="Test1" SortExpression="Test1" >
<ControlStyle Width="15%"></ControlStyle>
<ItemStyle Width="10%" />
</asp:BoundField>
<asp:BoundField HeaderText ="Test(2)"
ControlStyle-Width = "5%" DataField="Test2" SortExpression="Test2" >
<ControlStyle Width="5%"></ControlStyle>
<ItemStyle Width="10%" />
</asp:BoundField>
<asp:BoundField HeaderText ="Exams"
ControlStyle-Width = "35%" DataField="Exams" SortExpression="Exams" >
<ControlStyle Width="15%"></ControlStyle>
<ItemStyle Width="10%" />
</asp:BoundField>
<asp:BoundField HeaderText ="Total"
ControlStyle-Width = "5%" DataField="Total" SortExpression="Total">
<ControlStyle Width="5%"></ControlStyle>
<ItemStyle Width="5%" />
</asp:BoundField>
<asp:BoundField HeaderText ="Grade"
ControlStyle-Width = "5%" DataField="Grade" SortExpression="Grade" >
<ControlStyle Width="5%"></ControlStyle>
<ItemStyle Width="10%" />
</asp:BoundField>
<asp:BoundField HeaderText ="Remark"
ControlStyle-Width = "5%" DataField="Remark" SortExpression="Remark" >
<ControlStyle Width="5%"></ControlStyle>
<ItemStyle Width="10%" />
</asp:BoundField>
<asp:BoundField HeaderText ="Position"
ControlStyle-Width = "5%" DataField="ClassPosition">
<ControlStyle Width="5%"></ControlStyle>
<ItemStyle Width="10%" />
</asp:BoundField>
<asp:CommandField ShowEditButton="True" ShowCancelButton="False"
ButtonType="Button" />
</Columns>
<FooterStyle BackColor="#CCCCCC" />
<HeaderStyle BorderColor="#996633" BackColor="Black" ForeColor="White" Font-Bold="True"></HeaderStyle>
<PagerStyle BackColor="#990000" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
</asp:GridView>
|
|
|
|
|
I'd recommend adding that to the datasource of the grid, not the grid itself. Are you using SQL to load data in the grid?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|