rt
自己写的windows服务每次都比oracle数据库先启动,于是读数据库就失败,有没有什么好的方法?

解决方案 »

  1.   

    最简单的方法是让你的服务sleep一下,等数据库启动了在唤醒!!
      

  2.   

    LoadOrderGroup 
    LoadOrderGroupDependencies 
      

  3.   

    SC_HANDLE WINAPI CreateService(
      __in       SC_HANDLE hSCManager,
      __in       LPCTSTR lpServiceName,
      __in_opt   LPCTSTR lpDisplayName,
      __in       DWORD dwDesiredAccess,
      __in       DWORD dwServiceType,
      __in       DWORD dwStartType,
      __in       DWORD dwErrorControl,
      __in_opt   LPCTSTR lpBinaryPathName,
      __in_opt   LPCTSTR lpLoadOrderGroup,           
      __out_opt  LPDWORD lpdwTagId,
      __in_opt   LPCTSTR lpDependencies,    // see this member
      __in_opt   LPCTSTR lpServiceStartName,
      __in_opt   LPCTSTR lpPassword
    );
    lpDependencies    A pointer to a double null-terminated array of null-separated names of services or load ordering groups 
    that the system must start before this service. Specify NULL or an empty string if the service has no dependencies. 
    Dependency on a group means that this service can run if at least one member of the group is running after an 
    attempt to start all members of the group.    You must prefix group names with SC_GROUP_IDENTIFIER so that they can be distinguished from a service name,
     because services and service groups share the same name space.
      

  4.   

    这样不行,我本来都已经设置了lpDependencies了,不知道为什么连接不了数据库
    我用的是CDatabase类,数据库是oracle
      

  5.   

    已经搞定了,原来是oracle没有启动成功的时候我自己的程序连接不上,于是自己弹出一个odbc数据源对话框,由于是一个服务程序,所以对话框也不显示,但程序就停止在这里了,在CDatabase::openex函数中使用CDatabase::noOdbcDialog参数就可以了