Software Archive
Read-only legacy content
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
17060 Discussions

FindFirstFile example?

Intel_C_Intel
Employee
674 Views
I've got a Fortran DLL application and at one point in it I'd like to load all the DLLs that I find in a given directory. However, I don't know how many DLLs there might be or what their names are. Is a combination of FindFirstFile, FindNextFile and LoadLibrary my best bet and if so, is there an example that sonmeone could lead me to? I am already using LoadLibrary successfully (thanks to your previous responses). If those commands aren't the best way to do it, I would be pleased to hear any other suggestions.
Thanks in advance,
David
0 Kudos
1 Reply
Jugoslav_Dujic
Valued Contributor II
674 Views
Here's a piece of code from an actual app which copies all *.dat files from sBazaDir to sRadniDir folder and removes read-only attribute (it is used when the app detects that its working files are placed on a read-only medium like CD):

 
TYPE(T_WIN32_FIND_DATA)::     WFD 
INTEGER::                     hFile 
LOGICAL::                     bSt 
... 
hFile=FindFirstFile(TRIM(sBazaDir)//"*.dat"C, WFD) 
DO WHILE (.TRUE.) 
      iSt=CopyFile(WFD%cFileName, TRIM(sRadniDir)//""//WFD%cFileName, .FALSE.) 
      iSt=SetFileAttributes(TRIM(sRadniDir)//""//WFD%cFileName, FILE_ATTRIBUTE_NORMAL) 
      bSt=FindNextFile(hFile ,WFD) 
      IF (.NOT.bSt) EXIT 
END DO 


To me, it looks like you could apply it to your problem -- just use LoadLibrary instead of CopyFile. What do you want to obtain, actually?
Search for a library that contains a certain function?

Just a note which may be useful: you could also apply FindFirstFile to recursively traverse through subdirectories. If you apply GetFileAttributes
on WFD%cFileName and the result contains FILE_ATTRIBUTE_DIRECTORY flag, you can recursively apply the same operation on such WFD%cFileName.

Regards,

Jugoslav
0 Kudos
Reply