问题描述
我有一个C应用程序。
我想构建一个init函数这将创建将在init函数外部使用的事件的句柄
这样的事情:
InitEvents (HANDLE hEvent1,char * Event1Name,HANDLE hEvent2,char * Event2Name)
{
hEvent1 = CreateEvent(.. Event1Name ...);
hEvent2 = CreateEvent(.. Event2Name ...);
}
void main()
{
HANDLE h1,h2;
InitEvents(h1,ONE,h2,TWO);
SetEvent(hEvent1);
}
如何通过引用传递HANDLES所以创建的句柄将在主函数中可用?
谢谢!
什么我试过了:
声明InitEvents(HANDLE * hEvent1 .....)
hEvent1 = CreateEvent(。 .Event1Name ...);
Hi,
I have a C application.
I want to build an init function which creates handles to events which will be used outside the init function
Something like this:
InitEvents(HANDLE hEvent1, char *Event1Name, HANDLE hEvent2, char *Event2Name)
{
hEvent1 = CreateEvent(..Event1Name...);
hEvent2 = CreateEvent(..Event2Name...);
}
void main()
{
HANDLE h1,h2;
InitEvents(h1, "ONE", h2, "TWO");
SetEvent(hEvent1);
}
How can i pass the HANDLES by reference so the created handles will be available in the main function?
Thanks!
What I have tried:
Declaring the InitEvents(HANDLE *hEvent1.....)
hEvent1 = CreateEvent(..Event1Name...);
这篇关于C函数:如何传递HANDLE作为参考的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!