在win98第二版下用CreateDirectory创建目录:LPSECURITY_ATTRIBUTES m_dir;//m_dir用缺省值
CreateDirectory(str,m_dir);//str是CString类型
几天前用还可以成功,今天却不行了。
可是我这几天没做什么事呀!实在想不通,请一定帮忙。
请麻烦看一下问题所在,如果是m_dir未设定的话请告诉我m_dir应怎样设定(最离奇的是前几天明明可以用!),谢谢。§1 我这几天大致做的事:
用超级兔子清理注册表,结果不理想又恢复
上网google
上网csdn
上网the9
内存坏了换了一根,原来那根经修理重装
将网卡IP值设为固定
运行Diablo2毁灭之王
运行英雄无敌三死亡阴影选择网战,后中途退出§2 作为CreateDirectory参数的str的结构:
设我要在D盘M-1文件夹下建立M-2文件夹,str将等于"D:\M-1\M-2\"(其中\已经转义,代码中为\\)
§3 MSDN中对LPSECURITY_ATTRIBUTES类型的介绍The SECURITY_ATTRIBUTES structure contains the security descriptor for an object and specifies whether the handle retrieved by specifying this structure is inheritable. typedef struct _SECURITY_ATTRIBUTES { // sa 
    DWORD  nLength; 
    LPVOID lpSecurityDescriptor; 
    BOOL   bInheritHandle; 
} SECURITY_ATTRIBUTES; 
 
Members
nLength 
Specifies the size, in bytes, of this structure. Set this value to the size of the SECURITY_ATTRIBUTES structure. 
Windows NT/2000: Some functions that use the SECURITY_ATTRIBUTES structure do not verify the value of the nLength member. However, an application should still set it properly. That ensures current, future, and cross-platform compatibility. lpSecurityDescriptor 
Pointer to a security descriptor for the object that controls the sharing of it. If NULL is specified for this member, the object may be assigned the default security descriptor of the calling process. 
Windows 95/98: The lpSecurityDescriptor member of the structure is ignored. bInheritHandle 
Specifies whether the returned handle is inherited when a new process is created. If this member is TRUE, the new process inherits the handle. 
Res
A pointer to a SECURITY_ATTRIBUTES structure is used as a parameter in most kernel and window-management functions in the Win32 API that return a handle of an object.

解决方案 »

  1.   

    不行就来这个吧,一辈子也错不了
    __mkdir
      

  2.   

    LPSECURITY_ATTRIBUTES m_dir;//m_dir用缺省值
    CreateDirectory(str,m_dir);//str是CString类型是不是就这样两句,若是这个m_dir没有初始化使用很危险。明天吧给你弄个例子来。
      

  3.   

    LPSECURITY_ATTRIBUTES m_dir;//m_dir用缺省值
    CreateDirectory(str,m_dir);//str是CString类型是不是就这样两句,若是这个m_dir没有初始化使用很危险。明天吧给你弄个例子来。
    //////////////////////////////////////////////////////
    那为什么前几天我用的时候可以成功呢?(还有,我在Windows XP下试了一下,结果也是失败,而且程序还报错。)
      

  4.   

    great!(to akiy(宏))thank you!
    ///////////////////////////////////////
    我的帖子还请各位高手解决!
      

  5.   

    最新消息,将LPSECURITY_ATTRIBUTES m_dir
               CreateDirectory(str,m_dir);
    改成CreateDirectory(str,NULL);后可以成功!
      

  6.   

    临时自创了一个,
    SECURITY_ATTRIBUTES Sec_Att;
    Sec_Att.nLength = sizeof(SECURITY_ATTRIBUTES );
    Sec_Att.bInheritHandle = FALSE;
    Sec_Att.lpSecurityDescriptor = NULL;
    CreateDirectory("D:\\abc", &Sec_Att);你错的原因:
    LPSECURITY_ATTRIBUTES m_dir; //这个m_dir是指针,没有定位,你应是
    LPSECURITY_ATTRIBUTES m_dir = new SECURITY_ATTRIBUTES;
    .
    .
    CreateDirectory(str,m_dir);//str是CString类型
    delete m_dir;
    之所以前几天没事,是因为当事的系统内存结构没有变(由于m_dir没有定位,所以乱指于某一位置,几天后你装了一些软件,这个m_dir可能指了一些有内容的地方,所以错了)其实之前我也有过你的经历的,

    LPSYSTEMTIME lpSystime;
    GetSystemTime(lpSystime);
    结果Debug通过,Release不通过。
    正确是
    SYSTEMTIME   Systime;
    GetSystemTime(&Systime);

    LPSYSTEMTIME lpSystime = new SYSTEMTIME;
    GetSystemTime(lpSystime);
    delete lpSystime;