Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29235 Discussions

API Call fails to return anything (however works on another computer)

laddikey
Beginner
1,059 Views
I have a dll that contains the following code:
use dfwin

Character(256) path,path1
integer(4) pathln
pathln = GetModuleFileName (NULL, path1, pathln)

I am using Intel Fortran 9.0

On one computer, the call is fine. We find the path & pathlength. On 2 other development machines we get nothing. I am told that originally the path was indeed returned.

Does anyone have any ideas of what I should/could look for that would cause the API to return nothing. Note: it does not give any sort of errors and such, it simply returns and empty string & a 0 for the length.

Having asked the all important question "What changedd?" did not help. Also of note, I replaced the non functioning code with the funtioning (project files and all, literally everything that is contained in the parent folder) and still the API doesn't return an answer.

HELP!
0 Kudos
7 Replies
Steven_L_Intel1
Employee
1,059 Views
What does a subsequent GetLastError call return?
0 Kudos
Les_Neilson
Valued Contributor II
1,059 Views

What is the value of pathln passed into GetModuleFileName?

Les

0 Kudos
Jugoslav_Dujic
Valued Contributor II
1,059 Views
... that argument should be simply LEN(path1)
0 Kudos
laddikey
Beginner
1,059 Views
GetLastError returns a 6.

Although I have decared pathln, I have not set it's value at the time the call is made.
0 Kudos
laddikey
Beginner
1,061 Views
ahh, theres the rub JugoslavDujic, I actually am more interested in the path itself (hence the API call). I am indeed using the value of the length but it is the path that I am in search of.

Thanks
0 Kudos
Steven_L_Intel1
Employee
1,061 Views
Jugoslav is correct - the third argument is an input that is the size of the path buffer argument. It is not an output parameter. Since you're passing an uninitialized variable, the API routine may or may not decide that the buffer overflows.

If you want the length of the returned path you look at the function result.

Message Edited by Steve_Lionel on 04-18-2006 12:58 PM

0 Kudos
laddikey
Beginner
1,061 Views
Beautiful -- thanks Jugoslav & Steve, I misunderstood what you meant but you are correct, as soon as I changed that 3rd argument, it works.

I appreciate the help.
:)
0 Kudos
Reply