|
Not sure if that technique would work for DirectX games etc. It might not be low level enough.
I think hooks might be the only way to do it, and doing global hooks seems truly impossible to do entirely in .NET.
It's not too hard to get unmanaged code (C/C++/VB) to talk to managed code via a COM. That might be the easiest way: create a C/C++ hook, create a .NET class that gets wrapped as a COM component, let the hook call the .NET class.
This would allow you to do most of your development in C#, but I think some C/C++ is going to be unavoidable.
I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
-David St. Hubbins
|
|
|
|
|
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=1052&lngWId=10
This one is definately low level enough
seems it anyway
Public Class frmMain<br />
Inherits System.Windows.Forms.Form<br />
<br />
Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Integer, ByVal lpfn As LowLevelKeyboardProcDelegate, ByVal hMod As Integer, ByVal dwThreadId As Integer) As Integer<br />
Declare Function UnhookWindowsHookEx Lib "user32" Alias "UnhookWindowsHookEx" (ByVal hHook As Integer) As Integer<br />
Delegate Function LowLevelKeyboardProcDelegate(ByVal nCode As Integer, ByVal wParam As Integer, ByRef lParam As KBDLLHOOKSTRUCT) As Integer<br />
Declare Function CallNextHookEx Lib "user32" Alias "CallNextHookEx" (ByVal hHook As Integer, ByVal nCode As Integer, ByVal wParam As Integer, ByRef lParam As KBDLLHOOKSTRUCT) As Integer<br />
<br />
Const WH_KEYBOARD_LL = 13<br />
<br />
Structure KBDLLHOOKSTRUCT<br />
Dim vkCode As Integer<br />
Dim scanCode As Integer<br />
Dim flags As Integer<br />
Dim time As Integer<br />
Dim dwExtraInfo As Integer<br />
End Structure<br />
<br />
Dim intLLKey As Integer<br />
<br />
#Region " Windows Form Designer generated code "<br />
<br />
Public Sub New()<br />
MyBase.New()<br />
<br />
'This call is required by the Windows Form Designer.<br />
InitializeComponent()<br />
<br />
'Add any initialization after the InitializeComponent() call<br />
<br />
End Sub<br />
<br />
'Form overrides dispose to clean up the component list.<br />
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)<br />
If disposing Then<br />
If Not (components Is Nothing) Then<br />
components.Dispose()<br />
End If<br />
End If<br />
MyBase.Dispose(disposing)<br />
End Sub<br />
<br />
'Required by the Windows Form Designer<br />
Private components As System.ComponentModel.IContainer<br />
<br />
'NOTE: The following procedure is required by the Windows Form Designer<br />
'It can be modified using the Windows Form Designer. <br />
'Do not modify it using the code editor.<br />
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()<br />
Me.lblInfo = New System.Windows.Forms.Label()<br />
Me.SuspendLayout()<br />
'<br />
'lblInfo<br />
'<br />
Me.lblInfo.Location = New System.Drawing.Point(16, 16)<br />
Me.lblInfo.Name = "lblInfo"<br />
Me.lblInfo.Size = New System.Drawing.Size(216, 88)<br />
Me.lblInfo.TabIndex = 0<br />
Me.lblInfo.Text = "Alt-Tab, Alt-Esc, Ctrl-Esc, and the Windows key are disabled. Ctrl-Alt-Del and Al" & _<br />
"t-F4 are still enabled. Close the application to reset the keyboard. While this " & _<br />
"program is running, the low-level keyboard effect is global."<br />
'<br />
'frmMain<br />
'<br />
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)<br />
Me.ClientSize = New System.Drawing.Size(248, 118)<br />
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.lblInfo})<br />
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog<br />
Me.MaximizeBox = False<br />
Me.MinimizeBox = False<br />
Me.Name = "frmMain"<br />
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen<br />
Me.Text = "LowLevel Keyboard Hook"<br />
Me.ResumeLayout(False)<br />
<br />
End Sub<br />
<br />
#End Region<br />
<br />
Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<br />
intLLKey = SetWindowsHookEx(WH_KEYBOARD_LL, AddressOf LowLevelKeyboardProc, System.Runtime.InteropServices.Marshal.GetHINSTANCE(System.Reflection.Assembly.GetExecutingAssembly.GetModules()(0)).ToInt32(), 0)<br />
End Sub<br />
<br />
Private Sub frmMain_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing<br />
UnhookWindowsHookEx(intLLKey)<br />
End Sub<br />
<br />
Private Function LowLevelKeyboardProc(ByVal nCode As Integer, ByVal wParam As Integer, ByRef lParam As KBDLLHOOKSTRUCT) As Integer<br />
Dim blnEat As Boolean = False<br />
<br />
Select Case wParam<br />
Case 256, 257, 260, 261<br />
'Alt+Tab, Alt+Esc, Ctrl+Esc, Windows Key<br />
blnEat = ((lParam.vkCode = 9) AndAlso (lParam.flags = 32)) Or _<br />
((lParam.vkCode = 27) AndAlso (lParam.flags = 32)) Or _<br />
((lParam.vkCode = 27) AndAlso (lParam.flags = 0)) Or _<br />
((lParam.vkCode = 91) AndAlso (lParam.flags = 1)) Or _<br />
((lParam.vkCode = 92) AndAlso (lParam.flags = 1))<br />
End Select<br />
<br />
If blnEat = True Then<br />
Return 1<br />
Else<br />
Return CallNextHookEx(0, nCode, wParam, lParam)<br />
End If<br />
End Function<br />
Friend WithEvents lblInfo As System.Windows.Forms.Label<br />
End Class<br />
|
|
|
|
|
Hello folks,
I am new to windows .NET programing and was wondering how I could open a file with my application from the system context menu (open with...). My intuition told me that the specified file was probably encapsulated in the argument String array from my Main method, but my application craches when I try to do Explorer, right click on file -> Open with...-> MyApp.exe!
To resume: regular executing my exe works fine, opening my exe by open file with... (OS context menu) craches my application.
anybody knows how to do that ???
Thanks
|
|
|
|
|
Explorer passes the complete filename (including path) as the first argument to your entry point. You need to validate that an argument was provided and pass that to your main form when/after you instantiate it:
public class MainForm : Form
{
public static void Main(string[] args)
{
string filename = null;
if (args.Length > 0) filename = args[0];
Application.Run(new MainForm(filename));
}
public MainForm() : this(null)
{
}
private string filename;
public MainForm(string filename)
{
this.filename = filename;
}
public string Filename
{
get { return this.filename; }
set { this.filename = value; }
}
} Alternatively, you can use Environment.GetCommandLineArgs in your application somewhere to essentially do the same thing as was done in the Main entry point method.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
how to draw an X axis by datetime data!
my problem is to deal with the datetime,and the coordinate convert!
Please give me a sample!
|
|
|
|
|
|
I'm needing to be able to pull information off a computer (Computer Name, MAC Address, etc...), and am totally at a loss as to where to start (even to start looking). Could someone possibly point me in the right direction?
<---signature--->
Your kid gets into Duke.
You pay the tuition.
That tuition goes into my checking account.
My money in my checking account goes into beer, porn, and other such fun. Thank you
|
|
|
|
|
You can get some information with the Enviroment class, like Computer Name, OS Version, User, but the MAC Address I don't rememeber.
A example
string OSVersion = Environment.OSVersion.ToString();
----
hxxbin
|
|
|
|
|
Okay, that helps a lot, thank you. One other one while I'm at it: how would I be able to pull that same info off a remote machine, preferably by them accessing the exe themself from the server?
<---signature--->
Your kid gets into Duke.
You pay the tuition.
That tuition goes into my checking account.
My money in my checking account goes into beer, porn, and other such fun. Thank you
|
|
|
|
|
See Daniel's other response about using the Management classes to get remote information. There's several articles here on CodeProject about using those classes to get information from remote machines as well (which you can use to get information from your computer as well).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
|
For basic info, look at the System.Environment class. If you need more details, look at the System.Management.SelectQuery on the MSDN. With simple queries, you can get information about the machine, both the software and the hardware environment.
Perl combines all the worst aspects of C and Lisp: a billion different sublanguages in one monolithic executable. It combines the power of C with the readability of PostScript. -- Jamie Zawinski
|
|
|
|
|
i am using sharpdevelop ide to develop a c# application. i just want to know how to create a resource file for a cs file. i am able to add a empty resource file. but then i have the burden of entering all the values of the fields in the localized form. what is the easy way to do that. is it possible to convert a cs file into a resouce file or create a new resource file from a existing cs file.
where we need just enter the values not names. ie i have a label in cs file which is named label1 i want to the get the resource file with name label1 where i need only enter the text which should be seen in the place of the label. i think i have explained it more than enough.
Thanks in advance
|
|
|
|
|
Sorry mate I think you need vs.net to do this. C# builder personal does it as well if you want to try that :
http://www.borland.com/products/downloads/download_csharpbuilder.html
Perhaps you could write an add-in for #d but its probably not easy.
The smaller the mind the greater the conceit.
Aesop
|
|
|
|
|
The best place to find this information would be in the documentation (if any) for SharpDeveloper, or at their web site.
Note, resource files (ResX files) really have nothing specifically to do with C# source files (CS files). They are XML files that contain key/value pairs like so:
<?xml version="1.0" encoding="utf-8" ?>
<root>
<xsd:schema id="root" xmlns=""
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string"
minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string"
minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string"
minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string"
use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="ResMimeType">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="Version">
<value>1.0.0.0</value>
</resheader>
<resheader name="Reader">
<value>System.Resources.ResXResourceReader,
System.Windows.Forms, Version=1.0.3102.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="Writer">
<value>System.Resources.ResXResourceWriter,
System.Windows.Forms, Version=1.0.3102.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Value1">
<value>ValueText1</value>
</data>
<data name="Value2">
<value>ValueText2</value>
</data>
</root> Some designers like VS.NET provide design-time authoring for these file when the ResX file is associated with a component (like a Form ). I don't know if SharpDevelop does this becuase I've never had a need to use it. If it does, you can still author this stuff by hand. If you need to store a type other than a string, you can use the type attribute in the data element to specify the fully- or partly-qualified type (like System.Drawing.Size, System.Drawing ). The type just needs to have a TypeConverter associated with it to convert to and from strings.
For more information, see Resources in Applications[^] in the .NET Framework SDK.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi All,
I want to write an application which should display a pdf file, and some other features like searching,highlight text,zoom etc. Is there any free/paid controls available. I tried using pdf.ocx but it's very slow and also no feature for searching, highlight text etc. Any idea how to do this ?
Thanks
Mahesh Varma.
|
|
|
|
|
The Acrobat 6.0 ActiveX Control does have search and highlighting capability, as well as did 5.0 (maybe earlier versions as well, but I honestly don't remember). 6.0 has a button that literally reads "Search" and has a representative icon that 5.0 uses, binolculars - a common icon in many applications.
And since practically every computer has Adobe Acrobat (Reader) installed, you rarely have to worry about installing it. Just go to http://www.adobe.com[^].
If you want more options than this, please click "Search comments" at the top of the message forum because this has been covered many, many times before.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I Want to List the Table Names Of a MS Access Database Using ADO Connection.
This is How I tried
ADODB.Connection myConnection = new ADODB.ConnectionClass();
ADODB.Recordset rsTblNames = new ADODB.RecordsetClass();
if (optAccess.Checked)
{
ConnStr= "Provider=Microsoft.Jet.OLEDB.4.0;User ID=;Data Source="+ txtDbPath.Text +";Mode=ReadWrite;Extended Properties='';Jet OLEDB:System database='';Jet OLEDB:Registry Path='';Jet OLEDB:Engine Type=5;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False";
myConnection.Open(ConnStr,"","",0);
StrSql= "SELECT Name FROM MSysObjects WHERE Type = 1";
rsTblNames.Open(StrSql, myConnection, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockReadOnly,0);
}
But This returns a Error
|
|
|
|
|
Why don't you tell us what that error reads?
Besides, why are you using ADO.NET? It's much faster and for what you need can accomplish the same things. Your connection string doesn't change (although you could drop most of those options since they are mostly defaults and other unnecessary properties), nor does your SQL statement, just the code itself. This is, after all, the C# forum - a language targeting the CLR - so writing .NET applications and libraries is what this is about:
OleDbConnection conn = new OleDbConnection(string.Format(
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Mode=ReadWrite",
txtDbPath.Text));
OleDbCommand cmd = conn.CreateCommand();
cmd.CommandText = "SELECT Name FROM MSysObjects WHERE Type = 1";
OleDbDataReader reader = null;
try
{
conn.Open();
reader = cmd.ExecuteReader();
while (reader.Read())
{
Console.WriteLine(reader.GetString(0));
}
}
catch (Exception e)
{
Console.Error.WriteLine("An error occured: {0}", e.Message);
}
finally
{
if (reader != null) reader.Close();
conn.Close();
}
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
To get a list of table names:
code:--------------------------------------------------------------------------------
SELECT Name FROM MSysObjects WHERE Type = 1;
--------------------------------------------------------------------------------
To get list of query names:
code:--------------------------------------------------------------------------------
SELECT Name FROM MSysObjects WHERE Type = 5;
--------------------------------------------------------------------------------
additional information:
code:--------------------------------------------------------------------------------
To get list of Forms:
SELECT Name FROM MsysObjects WHERE Type =-32768;
To get list of Reports:
SELECT Name FROM MsysObjects WHERE Type = -32764;
To get list of Modules:
SELECT Name FROM MsysObjects WHERE Type = -32761;
To get list of Macros:
SELECT Name FROM MsysObjects WHERE Type = -32766;
|
|
|
|
|
Hello Friends
We are inviting you to hotdotnet.
hotdotnet is "a tip of day" messaging system which send a C# source
code (and also same object code with VB) everyday. Only one code for
a day. Visit and join today. Enjoy it!
http://groups.yahoo.com/group/hotdotnet/join
Your respectfully,
Nuri Yilmaz - Musa Dogramaci
|
|
|
|
|
Wrong message board, wrong name, and link not clickable...
|
|
|
|
|
|
Hey,
I try to bind a datasource to my combobox. The datasource is an array of objects.
Then I set the cmb01.displaymember = "Propertyname1".
Till here everything works fine.
But then I will also set the valuemember like this :
cmb01.ValueMember = "PopertyName2".
At runtime I receive always following exception :
"Could not bind to new display member. Parametername is newdisplaymember"
What will this mean? And how I have to resolve it?
Tkx,
Jac
|
|
|
|
|
I am trying to figure something out. I have a panel control that contain other controls (I think, I am looking at some one elses code) but for some reason, I can't see the other controls. I can go to the properties window (the dropdown) and select them but I can't see them on my screen (they won't even highlight if I select them in the property dropdown). I right clicked on the panel control, and menued the "send to back" but nothing happens. Also sometimes, just sometimes all the controls do appear and then for some reason (unknown at this time) the all..... disappear...
Anyone?
Ralph
|
|
|
|
|