Questions tagged [getmodulefilename]
25 questions
                    
                    28
                    
            votes
                
                6 answers
            
        How to properly use GetModuleFileName?
Following code:
#include 
#include 
using namespace std;
int main ()
{   LPWSTR buffer; //or wchar_t * buffer;
    GetModuleFileName(NULL, buffer, MAX_PATH) ;
    cout<
        
            
            
                
                    
    
    
        
    
    
                
            
        
       
        Sunrise
        
- 1,311
 - 3
 - 18
 - 28
 
                    15
                    
            votes
                
                9 answers
            
        How can I calculate the complete buffer size for GetModuleFileName?
The GetModuleFileName() takes a buffer and size of buffer as input; however its return value can only tell us how many characters is has copied, and if the size is not enough (ERROR_INSUFFICIENT_BUFFER).
How do I determine the real required buffer…
        
        Francis
        
- 11,388
 - 2
 - 33
 - 37
 
                    11
                    
            votes
                
                5 answers
            
        How do I GetModuleFileName() if I only have a window handle (hWnd)?
I'm trying to get the name of the executable of a window that is outside my C# 2.0 application. My app currently gets a window handle (hWnd) using the GetForegroundWindow() call from "user32.dll".
From the digging that I've been able to do, I think…
        
        Pretzel
        
- 8,141
 - 16
 - 59
 - 84
 
                    7
                    
            votes
                
                3 answers
            
        How to find the parent exe of a dll from inside the dll?
I need to do some stuff in a dll based on which process has loaded it. So being relatively new to windows programming I need help figuring out how to find the exe which loaded the current dll. So far I have been hard coding the exe file name, which…
        
        ash
        
- 1,170
 - 1
 - 15
 - 24
 
                    5
                    
            votes
                
                3 answers
            
        Does Chicken Scheme have an equivalent to Perl's $0?
How can I reliably get the script name in Chicken Scheme?
It seems that -ss eats up the script name, so it's not visible unless I use dot slash to run my scripts.
scriptedmain.scm:
#!/usr/bin/env csi -q
(display (command-line-arguments))
(display…
        
        mcandre
        
- 22,868
 - 20
 - 88
 - 147
 
                    5
                    
            votes
                
                2 answers
            
        Comparing two TCHAR's with same value results false
I am trying to check my applications path, and if it is not a specified path, then move it. I feel like my code is solid, yet it does not work properly.
TCHAR pCheck[MAX_PATH];
TCHAR…
        
        Josh Line
        
- 625
 - 3
 - 13
 - 27
 
                    2
                    
            votes
                
                2 answers
            
        GetModuleFileNameA returns weird results
I'm trying to get the name of a module loaded in another process with GetModuleFileNameA.
I've loaded a symbol using dbgHelp and got its module base address but 2 weird thing happen:
1. Sometimes GetModuleFileNameA returns system error codes 5:…
        
        Idov
        
- 5,006
 - 17
 - 69
 - 106
 
                    2
                    
            votes
                
                0 answers
            
        GetModuleFileName always return lowercase in service
i need to get path to current executable in service, but when using GetModuleFileNameW or global variable _pgmptr i always get lowercase path, which is incorrect for me.
example: original path is C:/MyApp/app.exe and GetModuleFileNameW  always…
        user4442454
                    2
                    
            votes
                
                1 answer
            
        GetModuleFileName not returning Path
I'm trying to get the current directory under win7 with VS c++ but
TCHAR pBuf[MAX_PATH];
int bytes = GetModuleFileName(NULL, pBuf, MAX_PATH);
std::cout << bytes << "   " << pBuf << "   " <<   GetLastError() << std::endl;
returns length 58 and what…
        
        user3049681
        
- 397
 - 4
 - 12
 
                    1
                    
            vote
                
                0 answers
            
        GetModuleFileNameW returns different path than GetCurrentDirectoryW (subst)
I have created a subst drive like the following: 
G:\ => F:\projects\projectname\
When I call GetModuleFileNameW
GetModuleFileNameW(GetModuleHandleW(nullptr), buffer2, MAX_PATH);
It returns the Module path using the original path, Ex:…
        
        CodingMadeEasy
        
- 2,257
 - 4
 - 19
 - 31
 
                    1
                    
            vote
                
                2 answers
            
        Can I retrieve a path, containing other than Latin characters?
I call GetModuleFileName function, in order to retrieve the fully qualified path of a specified module, in order to call another .exe in the same file, via Process::Start method.
However, .exe cannot be called when the path contains other than Latin…
        
        dempap
        
- 352
 - 1
 - 9
 - 21
 
                    1
                    
            vote
                
                1 answer
            
        Null-terminate a string in MASM / GetModuleFileName
In my program I call the GetModuleFileName function from the Windows API. The function tells me the path of the running .EXE file.
On Windows XP machines the string (szSrc) is not null-terminated according to the MSDN.
invoke…
        
        Alexander Maier
        
- 55
 - 5
 
                    1
                    
            vote
                
                2 answers
            
        How to get AppPath to Executable file's directory using C language on Windows (using MinGW gcc )
My executable file is in this place --> D:\Examples\C_Pro\newApp.exe
Also in that "C_Pro" folder contain several files ( file1.txt, file2.txt, file44.exe, newApp.c )
In my newApp.c file, I includes a ShellExecute Function to execute "file44.exe"…
        
        Aspen
        
- 53
 - 1
 - 9
 
                    1
                    
            vote
                
                2 answers
            
        What might getmodulefilename block on?
We have a multithreaded application.  One of the worker threads calls GetModuleFilename for logging purposes and we've seen a deadlock where the worker threads held a lock before calling GetModuleFilename which blocks forever.
We can and have…
        
        Mike Davis
        
- 197
 - 11
 
                    0
                    
            votes
                
                1 answer
            
        Rust get executable path of process by window handle or process id
I'm trying to get executable path of process on Windows OS. I have window handle coming from some windows event, from window handle I can acquire process id using GetWindowThreadProcessId(). Then, according to windows api docs I can use…
        
        dalvi
        
- 27
 - 5