Загрузка…





  • Сообщения   Поиск
  • kapitan-nemo20.11.2009 05:05   
    Anyone used SetFileInformationByHandle in practice for renaming of the files ,so that it worked - i.e. renamed the files?

    1)Anyone used SetFileInformationByHandle in practice for renaming of the files ,so
    that it worked - i.e. renamed the files? With what parameter to open handle file? Beside me this function DELETES the files , but does
    NOT RENAME them. Can be this function does not work? Possible bring detailed working example of the use
    SetFileInformationByHandle for renaming of the file? It Beforehand is much thanked.
    !my code:
    STRDISK="c" ! disk name
    str251="ABC.txt"
    STR251=ADJUSTL(STR251)
    string0="??"//STRDISK//":"
    filedir="??"//STRDISK//":"
    filename1="??"//STRDISK//":"//TRIM(STR251)

    hFile1=CreateFile(trim(filename1)//char(0),GENERIC_ALL + SYNCHRONIZE ,FILE_SHARE_READ + FILE_SHARE_WRITE , &
    0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0)

    hdir=CreateFile(trim(Filedir)//char(0), SYNCHRONIZE ,FILE_SHARE_READ+FILE_SHARE_WRITE, &
    0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0)




    filename2="??"//STRDISK//":"//TRIM(STR251)

    IRET = MultiByteToWideChar(CP_ACP,0,trim(filename2)//char(0),-1 , path2,SIZEOF(path2) ) !//char(0) !12 !11.txt




    IRET = MultiByteToWideChar(CP_ACP,0,trim(string0)//char(0),-1 , path,SIZEOF(path) ) !//char(0) !12 !11.txt

    ierror=getlasterror()

    string3='ABCDE.txt'
    string3=adjustl(string3)
    IRET = MultiByteToWideChar(CP_ACP,0 ,trim(string3)//char(0),-1 , path3,SIZEOF(path3) )


    fdi%RootDirectory=hdir
    fdi%ReplaceIfExists=1
    fdi%FileName=loc(path3)
    fdi%FileNameLength=sizeof(path3)



    IERROR=-1



    IRET= SetFileInformationByHandle(hFile1 , &
    4, &
    LOC(fdi), &
    sizeof(fdi) &
    );
    ! beside me IRET=1

    IERROR=GETLASTERROR() ! beside me IERROR=0

    flag=CloseHandle(hdir)
    flag=CloseHandle(hFile1)
    !========================================

    2) Was Not got also use the function ZwSetInformationFile - is given ierror= #C0000008 -STATUS_INVALID_HANDLE but handle is

    opened:

    !my code:
    ierror=-1
    IRET = MultiByteToWideChar(CP_ACP,0,trim(filename1)//char(0),-1 , path1,SIZEOF(path1) ) !//char(0) !12 !11.txt
    US%Buffer = LOC(path1)
    US%length=2*LEN_TRIM(STRING0)
    US%MaximumLength = SIZEOF(us)

    ObjectAttributes%Length = SIZEOF(ObjectAttributes)
    ObjectAttributes%RootDirectory =0
    ObjectAttributes%ObjectName =LOC(us)
    ObjectAttributes%Attributes=OBJ_KERNEL_HANDLE ! Z'0200' - OBJ_KERNEL_HANDLE !Z'0040' - OBJ_CASE_INSENSITIVE
    ObjectAttributes%SecurityDescriptor = 0
    ObjectAttributes%SecurityQualityOfService = 0

    ierror=-1
    irethandle =ZwOpenFile(FileHandle,GENERIC_READ + GENERIC_WRITE + SYNCHRONIZE &
    ,ObjectAttributes,IoStatusBlock,FILE_SHARE_READ+FILE_SHARE_WRITE+FILE_SHARE_DELETE &
    ,FILE_SYNCHRONOUS_IO_NONALERT) ! here irethandle=0 FileHandle=308 (i.e.>0)
    ierror=getlasterror()

    IRET = MultiByteToWideChar(CP_ACP,0,trim("??c:ABCD.txt")//char(0),-1 , path2,SIZEOF(path2) )
    fdizw%RootDirectory=0
    fdizw%ReplaceIfExists=1
    fdizw%FileName=loc(path2)
    fdizw%FileNameLength=sizeof(path2)

    ierror=-1
    iret= ZwSetInformationFile( FileHandle,IoStatusBlock ,LOC(fdizw),SIZEOF(fdizw),4) ! here iret=#C0000008
    ierror=getlasterror() ! here beside me ierror=0
    iret=closehandle(FileHandle)
    ierror=getlasterror()
    !---------------------------------------------------------
    !Tried to use instead of ZwOpenFile function ZwCreateFile:
    irethandle = ZwCreateFile(FileHandle, GENERIC_WRITE +  SYNCHRONIZE+DELETE ,ObjectAttributes &

    ,IoStatusBlock,NULL, &

    FILE_ATTRIBUTE_NORMAL,FILE_SHARE_READ+FILE_SHARE_WRITE+FILE_SHARE_DELETE,  FILE_OPEN, &

    FILE_SYNCHRONOUS_IO_NONALERT,0, 0 )
    ! here irethandle=#C000000D- STATUS_INVALID_PARAMETER





    !---------------------------------------------------------

    Operating system- Windows Vista. (in XP do not work too,Tried on miscellaneous computer)
    Anyone can me to help?Time has spent plenty of and do not understand - as possible correct?
    It Beforehand is much thanked.







Быстрый переход:  

Статистика форумов Intel Software Network

469 пользователей 539 тем и 6,214 сообщений.

За последние 24 часа появилось 0 новых тем 0 новых сообщений и 0 новых пользователей.

Самая популярная тема за последние 3 дня сортировка omp/tbb Больше всего ответов отправлено на сообщение Хотеть не вредно Наибольшее количество просмотров у сообщения сортировка omp/tbb

Приветствуем нового пользователя gameofthrones


Пожалуйста, обратитесь к странице Уведомление об оптимизации для более подробной информации относительно производительности и оптимизации в программных продуктах компании Intel.