|
Have I look at pinvoke.net [^] for the actual code to dump into VB or C# to use the p/invoke function.
As this is just normal code you can put it anywhere you like, even in seperate assemblies and referencing them.
For example to use MessageBox from user32.dll:
using System;
using System.Runtime.InteropServices;
public static class PInvokeHelper
{
[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern int MessageBox(IntPtr hWnd, string text, string caption, uint type);
}
public class TestInvoke
{
public void SayHello()
{
PInvokeHelper.MessageBox(IntPtr.Zero,"Hello, World!","Hello",0);
}
}
Hope this helps.
Graham.
|
|
|
|
|
yep! thats nice 1, this really solved my problem.
Kind Regards...
o O º(`'·.,(`'·., ☆,.·''),.·'')º O o°
»·'"`»* *☆ t4ure4n ☆* *«·'"`«
°o O º(,.·''(,.·'' ☆`'·.,)`'·.,)º O o°
|
|
|
|
|
Does any body has information how to get The P/Invoke Wizard
By: Paul Yao
The Paul Yao Company
o O º(`'·.,(`'·., ☆,.·''),.·'')º O o°
»·'"`»* *☆ t4ure4n ☆* *«·'"`«
°o O º(,.·''(,.·'' ☆`'·.,)`'·.,)º O o°
|
|
|
|
|
|
Seriously, did you even try?
Google "P/Invoke Wizard", and it's in the very first link.
--
I've killed again, haven't I?
|
|
|
|
|
I am writing a diagnostic tool for our application. This tool has to find and display if our website is added as a trusted site to internet explorer or not.
How can I find this? Can I find this from registry or somewhere else?
|
|
|
|
|
Is there any way to produce a new color by mixing two or more colors?
If yes then how do I mix two or more colors such that the new color is no way near the input colors (colors to be mixed)
By near I mean the new color must not be lighter or darker (intensity) color of the input colors.
Thank You.
|
|
|
|
|
|
I have main form that loads other UCs.
When I load certain UC, it loads data for that UC.
On each UC, I have buttons (eg. delete, add etc.).
I want that when I click on add button to add some data, automatically after adding that certain data, UC control reloads.
|
|
|
|
|
At first, what ASP.NET or WinForms platform do you use?
|
|
|
|
|
It's Windows Application.
|
|
|
|
|
Hello Everyone,
How can one detect if a printer is connected to the system or not.
I used the class System.Management.ManagementObjectSearcher class as follows :
System.Management.ManagementObjectSearcher searcher =
new System.Management.ManagementObjectSearcher("SELECT * FROM Win32_Printer");
the searcher.Get()returns printer objects even when not conneted to a printer. It detectes all printers that are installed on my computer.
and when the user clicks on Print (when offline) it throws an exception. How can I prevent this.
Can someone help me on this.
Thank you
-ZS
|
|
|
|
|
|
Hi,
I have generated a report using Crystal reports. The crystal reportviewer displays the report.
so as to automatically print the report i have a statement :
crystalReportViewer1.PrintReport();
When this statement is executed the Printer dialog box appears. How can this be disabled using c#.
Thanks for your help in advance.
-jzelma
|
|
|
|
|
Hi,
I am going to develeop an SMS module for PDAs. It will receive and send SMS messages. I will use OpenNETCF.Phone.Sms while developing this module.
I am looking for code samples and all kinds of sources that I can use.
Regards,
Sedso
|
|
|
|
|
I am writing a diagnostic tool for our application. This tool has to display the list of various .NET Framwork versions installed.
How can I do this? Can I find this from registry or somewhere else?
|
|
|
|
|
The following will add the SDK versions to a combo box named cboSDK and the Framework versions to cboFramework.
<br />
using Microsoft.Win32;<br />
<br />
GetRegValues("SOFTWARE\\Microsoft\\.NETFramework");<br />
<br />
<pre><br />
private Boolean GetRegValues(string cregPath)<br />
{<br />
RegistryKey rkeyMachine = Registry.LocalMachine;<br />
RegistryKey rkeySub = rkeyMachine.OpenSubKey(cregPath, RegistryKeyPermissionCheck.ReadSubTree);<br />
if (rkeySub == null)<br />
{<br />
MessageBox.Show("The registry key " + cregPath + " could not be opened.", "Registry Problem");<br />
return false;<br />
}<br />
else<br />
{<br />
string cValue = "";<br />
try<br />
{<br />
string cLeftValue = "sdkInstallRootv";<br />
foreach (string cvalueName in rkeySub.GetValueNames())<br />
{<br />
if (cvalueName.StartsWith(cLeftValue))<br />
{<br />
cValue = rkeySub.GetValue(cvalueName).ToString();<br />
if (cValue != string.Empty)<br />
{<br />
cboSDK.Items.Add(cvalueName.Replace(cLeftValue, "Version ") + " - " + cValue);<br />
}<br />
}<br />
else<br />
{<br />
if (cvalueName == "InstallRoot")<br />
{<br />
cValue = rkeySub.GetValue(cvalueName).ToString();<br />
if (cValue != string.Empty)<br />
{<br />
string[] cDirectories = System.IO.Directory.GetDirectories(cValue);<br />
<br />
foreach (string cDir in cDirectories)<br />
{<br />
if (System.IO.File.Exists(cDir + "\\ilasm.exe"))<br />
cboFramework.Items.Add(cDir);<br />
}<br />
}<br />
<br />
}<br />
}<br />
}<br />
}<br />
catch (Exception ex)<br />
{<br />
MessageBox.Show(ex.ToString(), "Error");<br />
return false;<br />
}<br />
finally<br />
{<br />
if (rkeySub != null)<br />
{ rkeySub.Close(); }<br />
<br />
}<br />
}<br />
return true;<br />
}
----------
There go my people. I must find out where they are going so I can lead them.
- Alexander Ledru-Rollin
|
|
|
|
|
At least I'm pretty sure there isn't a sql problem, the stored procedure works fine in query analyzer, but when I attempt to use it in my program it throws a SqlException:
Line 1: Incorrect syntax near 'NIDB_NIDBArticle_Search'.
Here is the SP:
<br />
CREATE PROCEDURE dbo.NIDB_NIDBArticle_Search<br />
(<br />
@term varchar(100)<br />
)<br />
AS<br />
SELECT<br />
a.article_id AS [ID],<br />
a.main_entry AS MainEntry,<br />
auth.last_name + ', ' + auth.first_name AS Author,<br />
ed.last_name + ', ' + ed.first_name AS Editor,<br />
a.assigned_word_count AS AssignedWordCount,<br />
s.status AS CurrentStatus <br />
FROM<br />
ARTICLE a<br />
JOIN [USER] auth ON a.author_id = auth.user_id<br />
JOIN [USER] ed ON a.editor_id = ed.user_id<br />
JOIN ASSIGNMENT m ON a.article_id = m.article_id<br />
JOIN LK_STATUS s ON m.status_id = s.status_id<br />
WHERE<br />
a.main_entry LIKE '%' + @term + '%'<br />
And here is the method, throws the exception when it attempts to fill the DataTable
<br />
public static DataTable Search(string term)<br />
{<br />
SqlCommand cmd = new SqlCommand("NIDB_NIDBArticle_Search", conn);<br />
SqlParameter parm = new SqlParameter("@parm", SqlDbType.VarChar);<br />
parm.Value = term;<br />
cmd.Parameters.Add(parm);<br />
SqlDataAdapter ad = new SqlDataAdapter();<br />
ad.SelectCommand = cmd;<br />
DataTable dt = new DataTable();<br />
ad.Fill(dt);<br />
conn.Close();<br />
<br />
return dt;<br />
}<br />
Any suggestions? I usually use Enterprise Library but for some reason I kept getting an infinite loop when I try to use it in this Windows form.
|
|
|
|
|
Set the CommandType property of the command to CommandType.StoredProcedure.
---
b { font-weight: normal; }
|
|
|
|
|
Yes that fixed... I feel foolish because I was thinking about that before I was finished then got distracted. When I came back it never poped back in my head.
|
|
|
|
|
i am using WMEncoder 9 sdk to encode a video from a camera, now i want to detect a voice on the screen so that i can know sound is recording or not, GetAudioLevel method is given in sdk but not implemented, is there work around anyone know.
Shajeel
|
|
|
|
|
Hi
Can anyone offer any advice on how to achieve on demand/paged population on tree controls for performance. How is this usually done in .NET?
Thanks in advance...
|
|
|
|
|
You add a "dummy" child node for every node whose real children have yet to be loaded. When a node is expanded you check if it has a dummy node, and if it does, remove the dummy node and add the real child nodes. The dummy node might have Text of "*" or some value which is meaningless in the context of your application.
The "advanced demo" in the sample app for my TreeViewWalker article uses load-on-demand: http://www.codeproject.com/cs/miscctrl/TreeViewWalker.asp[^]
Josh
|
|
|
|
|
private void DeactivateControls(ControlCollection ctl)<br />
{<br />
<br />
foreach (Control ctrl in ctl)<br />
{<br />
if (ctrl is MyTextBox)<br />
((MyTextBox)(ctrl)).EnabledSpecial = false;<br />
<br />
else<br />
(ctrl).Enabled = false;<br />
<br />
if (ctrl.HasChildren)<br />
DeactivateControls(ctrl.Controls);<br />
}<br />
}
MyTextBox.EnabledSpecial is still true after I try to set it to false in this method. What do I do wrong?
-- modified at 8:20 Friday 7th April, 2006
|
|
|
|
|
That depends on what the property EnableSpecial does. Without seeing that code, who knows what is going on?
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|