|
I mean google.com - where you type in something like "C# Cryptography" and get a ton of links to the sort of info you're after.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I need to get the coordinates of a click outside of my form, can anybody show me a quick example of doing this?
|
|
|
|
|
If you can interop it, there's a method for capturing the mouse so that you can get the first click, otherwise you need a system wide hook to catch mouse activity outside your form.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
could you give me an example on how to interop it?
|
|
|
|
|
Sure, I'll look it up for you
Here[^] is a CP article on the API
Here[^] is the API interop code.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
|
Sorry, but actually those articles didn't help me. Are there any examples for C#?
|
|
|
|
|
The SetCapture API is the only way outside of a global windows hook to capture the mouse at all outside your window. I'm not sure you can write a global hook in C#.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I'm using this code to get the mouse position with a timer interval of 10, and it works fine, I'm just not familar with the api enough to figure out how to check for clicks
<br />
[DllImport("user32.dll")]<br />
static extern bool GetCursorPos(ref Point lpPoint);<br />
<br />
private void timer1_Tick(object sender, System.EventArgs e)<br />
{<br />
Point defPnt = new Point();<br />
<br />
GetCursorPos(ref defPnt);<br />
<br />
<br />
<br />
MouseX = defPnt.X;<br />
<br />
MouseY = defPnt.Y;<br />
<br />
}<br />
|
|
|
|
|
Yes, you can query where the mouse is at any time, perhaps there is an API like it you can call to get the button state.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
|
Hi guys, This is what I am trying to do. Basically, I have a couple of data and I want to insert them into specific positions in a rich text box. Now i am able to copy the data onto the clipboard. the next step is to be able to move the caret to the specified index position and then be able to paste the data from the clip board. my question is, how do i make the caret to move to the specified index position.
thanks
Nana
|
|
|
|
|
There's a selectedText property, from memory. Whatever it is, you set the selected text to be the position you want, and a length of 0. This places the caret where you want it, without selecting anything.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
You are looking for the SelectionStart[^] property. Like Chris said, set SelectionLength to 0 and set SelectionStart to the caret position.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Please excuse me if im way off here, but I will try to communicate my goals well.
I have taken 1 class in C# and I am super green at it. I am attempting to create a database that several people in the US would have access to. We tried MS Access, but as you know it is a bit slow. I would like to create something a little faster. Im not only doing it to help myself and coworkers, but for the learning experience also.
To put it simply, the database I have in mind would simply consist of a form where we could enter information in several fields, and be able to retrieve it later... thats what a database is. My goal is to have the program access a simple txt file stored on a local drive that the program would access to get the information. I say a txt file, because this is all I was taught, and it was very basic. It was also stored on the local PC so the path name was simple.
Are there any suggestion to where I should start. Any good books, or source code I could get and manipulate.
Thanks for your time.
|
|
|
|
|
If it was me, I would use MySQL instead of a text file. It is free and open source (not that you would make changes to the underlying database engine) and there are plenty of administrative tools that are easy to use. Load the engine, create your tables and go.
On the C# side just create a dataset that reflects your database, populate the dataset at runtime, bind your dataset to your webform or windows form and enjoy the hours the microsoft people put in to make your life easy.
As far as references, I went to half price books and got an ADO.NET book, that is your best bet.
|
|
|
|
|
Use SQL Server Express or MSDE. They are free, and unlike MySQL they are free for commercial use, and they are not crap. Plus there is tons of info on the web on how to use them ( any info on connecting to SQL Server will work ).
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Im a bigtime newb, so I have a few questions. Will either one of these software packages provide me with the tools I need to create an interface with user, so they can add and retrieve data from the database. And a simple way to create a place to store the data. I know Im asking a lot here, I think I need to get some documentation. Any good sites?
|
|
|
|
|
frankie123 wrote: Will either one of these software packages provide me with the tools I need to create an interface with user, so they can add and retrieve data from the database.
No. You're asking in the C# forum, and you can use C# to build an interface. If you want everything done for you in a WYSIWYG fashion, then Access is definately the answer. If you were going to read a flat text file in code, then MSDE is a far better solution.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I am trying to impersonate a user to access a password protected network shared resource. (i.e Start>>Run>>"machine name", then enter user name and password) I am using Win2K. I know that the LogonUser doesn't work on Win2k unless the "Act as part of the operating system" priviledge is set. But that is not an option. I think I might need to use SSPI, but am unsure how to. Here is the code, but because I didn't set the "Act as part of the operating system" priviledge, I get the following error: ERROR_PRIVILEGE_NOT_HELD
1314
[DllImport("advapi32.DLL", SetLastError = true)]
public static extern int LogonUser(
string lpszUsername,
string lpszDomain,
string lpszPassword,
int dwLogonType,
int dwLogonProvider,
out IntPtr phToken);
private const int LOGON32_LOGON_INTERACTIVE = 2;
private const int LOGON32_PROVIDER_DEFAULT = 0;
private void ImpersonateValidUser(string userName, string domain, string password )
{
IntPtr iToken = new IntPtr(0);
try
{
iToken = IntPtr.Zero;
if (LogonUser(@userName, domain, password,
LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT,
out iToken) != 0)
{
WindowsIdentity id = new WindowsIdentity(iToken);
// Begin impersonation
impersonationContext = id.Impersonate();
RevertToSelf();
}
else
{
int ret = Marshal.GetLastWin32Error();
}
}
catch
{}
}
How do I use Windows Impersonation on Win2K and not set the "Act as part of the operating system" priviledge?
Any help would be greatly appreciated.
Thanks in advance!
|
|
|
|
|
Hello,
Is there a way of getting a current user logged on the machine?
Thank you.
|
|
|
|
|
using System.Threading;
using System.Security.Principal;
using System.Security.Permissions;
class xxyxyx{
Thread.CurrentPrincipal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
}
Include these two lines in your code. Then in Thread.CurrentPrinciple.Identity will have ur username.
|
|
|
|
|
|
After those two lines you can use this anywhere in the scope of that code.
Thread.CurrentPrincipal.Identity.Name
will give u the user name
|
|
|
|
|
Environment.UserName
If you just want to know which user started your process.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|