├── README.md ├── LICENSE └── nfd_python.py /README.md: -------------------------------------------------------------------------------- 1 | # nfd_python -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020-2022 hors 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /nfd_python.py: -------------------------------------------------------------------------------- 1 | import ctypes 2 | import sys 3 | 4 | sOS=sys.platform 5 | 6 | if sOS=="win32": 7 | if ctypes.sizeof(ctypes.c_voidp)==4: 8 | hllDll=ctypes.CDLL("win32/nfd.dll") 9 | elif ctypes.sizeof(ctypes.c_voidp)==8: 10 | hllDll=ctypes.CDLL("win64/nfd.dll") 11 | 12 | NFD_CreateScanHandle=hllDll.NFD_CreateScanHandle 13 | NFD_CreateScanHandle.restype=ctypes.c_int 14 | 15 | NFD_ScanFileA=hllDll.NFD_ScanFileA 16 | NFD_ScanFileA.restype=ctypes.c_char_p 17 | NFD_ScanFileA.argtypes=[ctypes.c_int,ctypes.c_char_p,ctypes.c_int] 18 | 19 | NFD_CloseScanHandle=hllDll.NFD_CloseScanHandle 20 | NFD_CloseScanHandle.argtypes=[ctypes.c_int] 21 | 22 | ##SF_RECURSIVE =0x00000001, 23 | ##SF_DEEPSCAN =0x00000002, 24 | ##SF_RESULTASXML =0x00000004, 25 | ##SF_RESULTASJSON =0x00000008, 26 | ##SF_HEURISTICSCAN =0x00000010, 27 | 28 | nFlags=(ctypes.c_int)(1|2) 29 | 30 | sFileName="C:/Windows/regedit.exe" 31 | 32 | b_sFileName=sFileName.encode('utf-8') 33 | 34 | hHandle=(ctypes.c_int)(NFD_CreateScanHandle()) 35 | sResult=NFD_ScanFileA(hHandle,b_sFileName,nFlags) 36 | 37 | print (sResult.decode("utf-8")) 38 | 39 | NFD_CloseScanHandle(hHandle) 40 | 41 | 42 | --------------------------------------------------------------------------------