只运行一个程序,多用户登录仍然有效,如何实现?

flitooo 2010-01-25 10:36:40
无论多少用户登录到系统,程序只能运行一个!

不要告诉我用Mutex,Mutex对多用户登录是无效的。
...全文
189 5 打赏 收藏 举报
写回复
5 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
flitooo 2010-01-25
  • 打赏
  • 举报
回复

谢谢 budded

budded 2010-01-25
  • 打赏
  • 举报
回复
Mutex怎么会无效?哈哈,没读懂参数使用方法吧,

lpName
The name of the mutex object. The name is limited to MAX_PATH characters. Name comparison is case sensitive.

If lpName matches the name of an existing named mutex object, this function requests the MUTEX_ALL_ACCESS access right. In this case, the bInitialOwner parameter is ignored because it has already been set by the creating process. If the lpMutexAttributes parameter is not NULL, it determines whether the handle can be inherited, but its security-descriptor member is ignored.

If lpName is NULL, the mutex object is created without a name.

If lpName matches the name of an existing event, semaphore, waitable timer, job, or file-mapping object, the function fails and the GetLastError function returns ERROR_INVALID_HANDLE. This occurs because these objects share the same name space.

The name can have a "Global\" or "Local\" prefix to explicitly create the object in the global or session name space. The remainder of the name can contain any character except the backslash character (\). For more information, see Kernel Object Namespaces. Fast user switching is implemented using Terminal Services sessions. The first user to log on uses session 0, the next user to log on uses session 1, and so on. Kernel object names must follow the guidelines outlined for Terminal Services so that applications can support multiple users.

Windows 2000: If Terminal Services is not running, the "Global\" and "Local\" prefixes are ignored. The remainder of the name can contain any character except the backslash character.
The object can be created in a private namespace. For more information, see Object Namespaces.
brightyang 2010-01-25
  • 打赏
  • 举报
回复
弄一个服务器验证呗
flitooo 2010-01-25
  • 打赏
  • 举报
回复
程序只允许运行一个实例,windows系统支持多用户登录同时登录,但我的程序无论多少用户登录,也只允许让它运行一个实例。以前用Mutex来达到运行一个实例的效果,但如果有另一个用户登录系统,其实它仍是可以运行这个程序的。。
wzwcn 2010-01-25
  • 打赏
  • 举报
回复
不明白你的意思。是不是一个用户名只能登录一次,一个同户名不能同时登录?
相关推荐
发帖
Windows SDK/API

1177

社区成员

Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
帖子事件
创建了帖子
2010-01-25 10:36
社区公告
暂无公告