调用CreateMutex创建一个有名的互斥器对象
2007-07-27 15:51
387 查看
void NameMutexExample (void) {
HANDLE hMutex;
TCHAR szMsg[100];
hMutex = CreateMutex (
NULL, //No security descriptor
FALSE, //Mutex object not owned
TEXT("NameOfMutexObject")); //Object name
if (NULL == hMutex) {
//Your code to deal with the error goes here.
//Here is one example of what might be done.
wsprintf (szMsg, TEXT("CreateMutex error: %d."), GetLastError ());
MessageBox (NULL, szMsg, TEXT("Error"), MB_OK);
else {
//Not an error -- deal with success
if ( ERROR_ALREDAY_EXISTS == GetLastError ())
MessageBox (NULL, TEXT("CreateMutex opened existing mutex."),
TEXT("Results"),MB_OK);
else
MessageBox (NULL, TEXT("CreateMutex created new mutex."),
TEXT("Result"), MB_OK);
}
} //End of NamedMutexExamle code
HANDLE hMutex;
TCHAR szMsg[100];
hMutex = CreateMutex (
NULL, //No security descriptor
FALSE, //Mutex object not owned
TEXT("NameOfMutexObject")); //Object name
if (NULL == hMutex) {
//Your code to deal with the error goes here.
//Here is one example of what might be done.
wsprintf (szMsg, TEXT("CreateMutex error: %d."), GetLastError ());
MessageBox (NULL, szMsg, TEXT("Error"), MB_OK);
else {
//Not an error -- deal with success
if ( ERROR_ALREDAY_EXISTS == GetLastError ())
MessageBox (NULL, TEXT("CreateMutex opened existing mutex."),
TEXT("Results"),MB_OK);
else
MessageBox (NULL, TEXT("CreateMutex created new mutex."),
TEXT("Result"), MB_OK);
}
} //End of NamedMutexExamle code
相关文章推荐
- 编写类A,该类创建的对象包含一个方法f输出英文字母表,再编写一个A类的子类B,要求必须继承A类的方法f(不允许重写),子类创建的对象不仅可以调用方法f输出英文字线表,而且调用子类新增的方法g输出希腊字
- CreateMutex创建互斥内核对象
- 关于“如何做到在一个类内不通过创建另一个类的对象,却调用另一个类的方法”的问题
- java创建一个子类对象是会调用父类的构造方法会不会创建父类
- java程序练习:尝试创建一个父类,在父类中创建两个方法,在子类中覆盖第二个方法,为子类创建一个对象,将他向上转型到基类并调用这个方法。
- java创建一个子类对象是会调用父类的构造方法会不会创建父类
- Java抽象类不可创建对象,但可以调用静态方法将建一个对象
- java创建一个子类对象是会调用父类的构造方法会不会创建父类
- 定义一个包含私有成员变量和函数的类,再定义一个内部类,在内部类函数中访问外部成员变量,并调用外部函数。在外部类函数中创建内部类对象,调用内部类函数
- WINDOWS API ——CREATEMUTEX——创建互斥对象 http://www.cnblogs.com/wind-net/archive/2012/08/29/2661702.html
- 创建一个对象,构建器(构造器)的调用顺序是如何的?
- 5.编写一个程序,有两个类,其中类MAX中具有两个方法,方法名都是max,一个方法能够比较两个数的大小,另外一个方法能够比较三个数的大小。在另外一个类中创建对象,调用这两个方法,分别输出两组数:2、6
- java 和 JavaScript都可以在创建一个对象时,就可以通过这个对象调用相应方法
- 编写一个文件,读取 src 下面day12包 下面的my.properties 文件,文件内容如下, className=day12.User 结合 IO、反射知识,完成 配置文件中对象的创建和方法调用。并编写方法,列举出 Student 类中所有的属性、
- 尝试创建一个父类,在父类中创建两个方法,在子类中覆盖第二个方法,为子类创建一个对象,将它向上转型到基类并调用这个方法。
- 创建互斥对象,让程序只运行一个。
- 简单工厂(Factory)-提供一个创建对象实例的功能,而无须关心其具体实现。被创建实例的类型可以是接口、抽象类,也可以是具体的类。
- 对象的创建和调用方法以及操作字段
- java----序列化与反序列化中及java序列化本质就是存储一个对象,然后在其他地方在调用它
- 设计只允许创建一个对象的类