DeviceIoControl for HMG

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
AUGE_OHR
Posts: 2060
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

DeviceIoControl for HMG

Post by AUGE_OHR »

hi,

to "safe eject" USB-Drive i need DeviceIoControl
https://docs.microsoft.com/en-us/window ... eiocontrol

when call "direct" it say unkown so i try HB_FUNC
Harbour 3.2.0dev (r1703241902)
Copyright (c) 1999-2016, http://harbour-project.org/
C:\hmg.3.4.4\0\USBEJECT\HB_FUNC.PRG: In function 'HB_FUN_DeviceIoControl':
C:\hmg.3.4.4\0\USBEJECT\HB_FUNC.PRG:481:6: error: conflicting types for 'DeviceIoControl'
BOOL DeviceIoControl(
^
In file included from C:/hmg.3.4.4/mingw/i686-w64-mingw32/include/winbase.h:21:0,
from C:/hmg.3.4.4/mingw/i686-w64-mingw32/include/windows.h:70,
from C:\hmg.3.4.4\0\USBEJECT\HB_FUNC.PRG:4:
C:/hmg.3.4.4/mingw/i686-w64-mingw32/include/ioapiset.h:22:29: note: previous declaration of 'DeviceIoControl' was here
WINBASEAPI WINBOOL WINAPI DeviceIoControl (HANDLE hDevice, DWORD dwIoControlCode, LPVOID lpInBuffer, DWORD nInBufferSize, LPVOID lpOutBuffer, DWORD nOutBufferSize, LPDWORD lpBytesReturned, LPOVERLAPPED lpOverlapped);
^
hbmk2[HBEJECT]: Error: Running C/C++ compiler. 1
gcc.exe -c -O3 -march=i586 -mtune=pentiumpro -fomit-frame-pointer -W -Wall -pipe -IC:/hmg.3.4.4/harbour/include -IC:/hmg.3.4.4/0/USBEJECT -IC:/hmg.3.4.4/include R:/Temp/hbmk_5bvogs.dir/HBEJECT.c R:/Temp/hbmk_5bvogs.dir/HB_FUNC.c R:/Temp/hbmk_sf02sk.c
Ok, my Syntax is wrong but if i understand right 'DeviceIoControl' is already define ... so what do i miss :?:
i have try to include LIBs

Code: Select all

libpaths=c:\harbour\comp\mingw\lib
libs=kernel32
libs=ntoskrnl
libs=win32k 
libs=ntdll
but it does not help.
any Idea :idea:


hole Articel is here
https://docs.microsoft.com/en-us/window ... e-a-device
have fun
Jimmy
User avatar
AUGE_OHR
Posts: 2060
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: DeviceIoControl for HMG

Post by AUGE_OHR »

hi

got it so far but i need Windows Structure PREVENT_MEDIA_REMOVAL found in

C:\hmg.3.4.4\MINGW\i686-w64-mingw32\include\winioctl.h

Code: Select all

  typedef struct _PREVENT_MEDIA_REMOVAL {
    BOOLEAN PreventMediaRemoval;
  } PREVENT_MEDIA_REMOVAL,*PPREVENT_MEDIA_REMOVAL;
when try to copy/paste it to my HB_FUNC.PRG it say "dupe" :shock:
Harbour 3.2.0dev (r1703241902)
Copyright (c) 1999-2016, http://harbour-project.org/
C:\hmg.3.4.4\0\HBFM\HB_FUNC.PRG:480:18: error: redefinition of 'struct _PREVENT_MEDIA_REMOVAL'
typedef struct _PREVENT_MEDIA_REMOVAL {
^
In file included from C:/hmg.3.4.4/mingw/i686-w64-mingw32/include/winscard.h:11:0,
from C:/hmg.3.4.4/mingw/i686-w64-mingw32/include/windows.h:97,
from C:\hmg.3.4.4\0\HBFM\HB_FUNC.PRG:4:
C:/hmg.3.4.4/mingw/i686-w64-mingw32/include/winioctl.h:231:18: note: originally defined here
typedef struct _PREVENT_MEDIA_REMOVAL {
^
C:\hmg.3.4.4\0\HBFM\HB_FUNC.PRG:482:5: error: conflicting types for 'PREVENT_MEDIA_REMOVAL'
} PREVENT_MEDIA_REMOVAL,*PPREVENT_MEDIA_REMOVAL;
^
In file included from C:/hmg.3.4.4/mingw/i686-w64-mingw32/include/winscard.h:11:0,
from C:/hmg.3.4.4/mingw/i686-w64-mingw32/include/windows.h:97,
from C:\hmg.3.4.4\0\HBFM\HB_FUNC.PRG:4:
C:/hmg.3.4.4/mingw/i686-w64-mingw32/include/winioctl.h:233:5: note: previous declaration of 'PREVENT_MEDIA_REMOVAL' was here
} PREVENT_MEDIA_REMOVAL,*PPREVENT_MEDIA_REMOVAL;
^
C:\hmg.3.4.4\0\HBFM\HB_FUNC.PRG:482:28: error: conflicting types for 'PPREVENT_MEDIA_REMOVAL'
} PREVENT_MEDIA_REMOVAL,*PPREVENT_MEDIA_REMOVAL;
^
In file included from C:/hmg.3.4.4/mingw/i686-w64-mingw32/include/winscard.h:11:0,
from C:/hmg.3.4.4/mingw/i686-w64-mingw32/include/windows.h:97,
from C:\hmg.3.4.4\0\HBFM\HB_FUNC.PRG:4:
C:/hmg.3.4.4/mingw/i686-w64-mingw32/include/winioctl.h:233:28: note: previous declaration of 'PPREVENT_MEDIA_REMOVAL' was here
} PREVENT_MEDIA_REMOVAL,*PPREVENT_MEDIA_REMOVAL;
^
hbmk2[HBFM]: Error: Running C/C++ compiler. 1
gcc.exe -c -O3 -march=i586 -mtune=pentiumpro -fomit-frame-pointer -es1 -W -Wall -pipe -IC:/hmg.3.4.4/harbour/include -IC:/hmg.3.4.4/0/HBFM -IC:/hmg.3.4.4/include R:/Temp/hbmk_l50l0c.dir/HBFM.c R:/Temp/hbmk_l50l0c.dir/ASKFORM.c R:/Temp/hbmk_l50l0c.dir/AUSWAHL.c R:/Temp/hbmk_l50l0c.dir/Browser.c R:/Temp/hbmk_l50l0c.dir/DBF2FMG.c R:/Temp/hbmk_l50l0c.dir/FMCOLOR.c R:/Temp/hbmk_l50l0c.dir/FMSETUP.c R:/Temp/hbmk_l50l0c.dir/FMSTACK.c R:/Temp/hbmk_l50l0c.dir/FMTOOL.c R:/Temp/hbmk_l50l0c.dir/FM_FUNC.c R:/Temp/hbmk_l50l0c.dir/HBEJECT.c R:/Temp/hbmk_l50l0c.dir/HB_FUNC.c R:/Temp/hbmk_l50l0c.dir/HELPFILE.c R:/Temp/hbmk_l50l0c.dir/Shell32.c R:/Temp/hbmk_l50l0c.dir/VIEWER.c R:/Temp/hbmk_x1izd1.c
when try to #include "winioctl.h" in PRG i got lot Error Message :(

need help please

p.s. this it the "safe" Part, all other is working now
have fun
Jimmy
Post Reply