473,396 Members | 1,843 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

OpenEvent SetEvent

I have to translate this code in VB6 in C#:

Declare Function OpenEvent Lib "kernel32.dll" Alias "OpenEventA" _
(ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, _
ByVal lpName As String) _
As Long

Declare Function SetEvent Lib "kernel32.dll" _
(ByVal hEvent As Long) _
As Long

Public Const EVENT_MODIFY_STATE As Long = 2

Private Sub sendTrap()
Dim sdsTrap As Long
sdsTrap = OpenEvent(EVENT_MODIFY_STATE, 0, "_sdsTrapEvent")
If sdsTrap <> 0 Then
SetEvent(sdsTrap)
End If
End Sub

I tried this:

public const int EVENT_MODIFY_STATE = 2;

[DllImport("KERNEL32.DLL", EntryPoint="OpenEventA")]
private static extern long OpenEvent
(
long dwDesiredAccess,
long bInheritHandle,
[MarshalAs(UnmanagedType.LPStr)] string lpName
);

[DllImport("KERNEL32.DLL")]
private static extern bool SetEvent
(
long hEvent
);

public void sendTrap()
{
long sdsTrap;
sdsTrap = OpenEvent(EVENT_MODIFY_STATE, 0, "_sdsTrapEvent");
if (sdsTrap != 0)
{
SetEvent (sdsTrap);
}
}

The OpenEvent seems to be ok, but the SetEvent fails (I tested and it
returns false).

How could I do this?

Thanks in advance, Gionni
Nov 15 '05 #1
2 11688

[DllImport("KERNEL32.DLL", CharSet=CharSet.Auto)]
private static extern IntPtr OpenEvent
(
uint dwDesiredAccess,
bool bInheritHandle,
string lpName
);

[DllImport("KERNEL32.DLL")]
private static extern bool SetEvent
(
IntPtr hEvent
);

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Nov 15 '05 #2
Mattias Sjögren <ma********************@mvps.org> wrote in message news:<u4*************@TK2MSFTNGP11.phx.gbl>...

Thanks a lot, Mattias. I did not know where I could find the right signatures.

Cheers, Gionni
Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Markus von Ehr | last post by:
Hi everybody, I'd like to create an event which I have to post/set within an extension (new frame signal from a camera). In python I would like to react on this event. How could I create and...
18
by: jas | last post by:
Hi, I would like to start a new process and be able to read/write from/to it. I have tried things like... import subprocess as sp p = sp.Popen("cmd.exe", stdout=sp.PIPE)...
8
by: Paul | last post by:
Hi all may I know how to use C# DLL inside my VC++ Project ? Thanks in advance.
3
by: Sharon | last post by:
I need to use some kind of signaling among processes, but the only thing I found that can something like that is the Mutex. But the Mutex doesn’t have a real signaling, it only has Wait() and...
14
by: pmud | last post by:
Hi, I need to use an Excel Sheet in ASP.NET application so that the users can enter (copy, paste ) large number of rows in this Excel Sheet. Also, Whatever the USER ENETRS needs to go to the...
6
by: Jon | last post by:
I have a service program that creates a crystal report and prints the report to a named printer driver. The printer driver raises an event when it is finished. I am supposed to trap for the...
4
by: Dale Strickland-Clark | last post by:
In Linux this is easy with 'signal' and 'kill' but how can I get one Python process to signal another (possibly running as a service)? All I need is a simple prod with no other data being sent...
3
by: Abubakar | last post by:
Hi, I created 2 functions which run in seperate threads. what they do simply is that thread1 starts and does something while the thread 2 waits for it. Then after thread1 is done, it resumes the...
3
by: romcab | last post by:
Hello guys, I'm very new in .NET development and I was forced to learn it since my current project should used it. Anyway can you help me guys if you know the equivalent of PostMessage in...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.