|
You have a couple of options without having to go that far. First you can use the System.Convert class to Convert a bool to any number type like:
bool b = true;
Convert.ToByte(b); //Returns 1
Also if you are using ADO.NET you can use paramaters instead of String building your SQL statement. It will handle the boolean to SQL bit field for you.
|
|
|
|
|
Ah. I had tried that with ToInt32 and it didn't work, so I went on this bizarre quest. However, trying your example, using ToInt32, now it does work. I must have done something wrong originally!
Thank you for your response, and I'll look at parameters too!
Marc
|
|
|
|
|
Is there any way to clear the Console screen with managed code ?
Mauricio Ritter - Brazil
Sonorking now: 100.13560 Trank
The alcohol is one of the greatest enemys of man, but a man who flee from his enemys is a coward.
|
|
|
|
|
If you still haven't found a solution, you could do a *work around* by creating a function with a for loop to clear it.
void ClearScreen()
{
for(i = 0; i < 24; i++)
{
Console.WriteLine("\n");
}
}
HTH
Nick Parker
|
|
|
|
|
In my code I have created a new process (with CreateProcess)
and I need the handle (HWND) of the process's window.
but I couldn't figure how to find the new process's related window.
For example, I create a new "NotePad" process.
later I need to send a message to the "NotePad"
how???
if any one can help me
thanks!
Eynat
|
|
|
|
|
I think you can use the DllImport to use the window's api in dll to finish this job.
I'm amumu, and you?
|
|
|
|
|
Thank you for your respond.
Can U please write me a small example - couse I didn't understand what you ment.
Eynat.
|
|
|
|
|
He means you can use API.Here an example of importing kernel32.dll:
http://www.codeproject.com/cs/miscctrl/drivecombobox.asp
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
You mentioned CreateProcess, are you using the WinAPI CreateProcess? Or are you referring to a process created with System.Diagnostics.Process.Start()? Either way you can use this class to bind to a process if you have its PID or even just the process name (executable). Once bound use the Handle property to get the HWND.
|
|
|
|
|
here some code i used for the winamp api
<br />
[DllImport("user32.dll")]<br />
public static extern int FindWindow(string c,int d);<br />
[DllImport("user32.dll")]<br />
public static extern int SendMessage(int hWnd,int msg, int wparam, int lparam);<br />
hope it helps
|
|
|
|
|
Hi, dunno if this can be done or how...
text from MIRC help file:
This section contains technical information for programmers who want to create DLLs for use with mIRC.
The routine in the DLL being called must be of the form:
int __stdcall procname(HWND mWnd, HWND aWnd, char *data, char *parms, BOOL show, BOOL nopause)
The question is how would implement such a function in C# the can be accessed by MIRC. MIRC also allows for calling COM objects. Would this be an easier solution perhaps
Any help would be really grateful
|
|
|
|
|
Can you code like the following?
[DllImport("kernel32", SetLastError=true)]
static extern unsafe int CreateFile(
string filename,
uint desiredAccess,
uint shareMode,
uint attributes,
uint creationDisposition,
uint flagsAndAttributes,
uint templateFile);
I'm amumu, and you?
|
|
|
|
|
hello?
from what i can see you are using an external function in C# here. I want an external app to use a C# dll.
|
|
|
|
|
|
Thx for all the quick replies
Just one reason to come back for more
After some investigation it seems the COM way is the way to go.
|
|
|
|
|
just a stupid question: i presume this CCW cant be written in C#, can it?
|
|
|
|
|
leppie wrote:
just a stupid question: i presume this CCW cant be written in C#, can it?
It can. Write your DLL using C#. Now using Regasm.exe you can register your C# DLL as a COM component. This allows COM clients to instantiate and use your class as if it was in a normal COM DLL.
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
|
|
|
|
|
Thx Nish but it does not seem to work as I think it should. Have a look at example.
<br />
using System;<br />
<br />
namespace MircDll<br />
{<br />
public class MircDll<br />
{<br />
public static int Test(ref string test)<br />
{<br />
test = "HELP me I'M in TROUBLE";<br />
return 1;<br />
}<br />
}<br />
}<br />
I compile then run regasm, but mirc cannot see this as a COM object. What else do i need? Or is Mirc just plain evil?
I will try some more anyways
|
|
|
|
|
I've not looked into calling managed code from an unmanaged app but I very much doubt that MIRC would call a C# dll, you'd be better sticking to C++.
Michael
"Eureka" is Greek for "This bath is too hot"
|
|
|
|
|
F:\Dev\ASP.NET\dw\CRC32.cs(87): Operator '<<' cannot be applied to operands of type 'int' and 'uint'
For some reason it doesn't like rv |= 1 << (c - i); ??
protected static uint Reflect(uint val, byte c)
{
uint rv = 0;
for (uint i=1; i<(c + 1); i++)
{
if ((val & 1) != 0)
{
rv |= 1 << (c - i);
}
val >>= 1;
}
return rv;
}
Todd Smith
|
|
|
|
|
i haven't tried, but 1 is a integer-constant
maybe this works:
int one=1;
rv |= one << (c-i);
just an idea...
:wq
|
|
|
|
|
You can write like this:
rv |= (uint)(1 << (int)(c - i));
I'm amumu, and you?
|
|
|
|
|
works like a charm.
thanks
Todd Smith
|
|
|
|
|
Hi,
I'm preparing for "Exam 70-316*—Developing and Implementing Windows-based Applications with Microsoft Visual C# .NET and Microsoft Visual Studio .NET".
Any suggestion\help and cpmments would be apprecaited.
Kasturi
|
|
|
|
|
I always think C# is more same as Delphi in develop windows application:
drag and drop;
hanlde event call back function.
I'm amumu, and you?
|
|
|
|