#include
int main()
{
char file[16];
char func[16];
sprintf(file,__FILE__); //文件名
sprintf(func,__FUNCTION__);//函数名
printf("file=%s\n",file);
printf("func=%s\n",func);
return 0;
}
调用
char buff[1000];
if(GetRunningPath(buff, 1000))
....
#include
//////////////
bool GetRunningPath(char* buff, int bufflen)
{
char path[MAX_PATH];
memset(path, 0, MAX_PATH);
DWORD nSize = ::GetModuleFileName(NULL, path, MAX_PATH);
if(nSize==MAX_PATH)
{
if(ERROR_INSUFFICIENT_BUFFER==GetLastError())
return FALSE; // error
}
path[nSize]='\0';
sprintf_s(buff, bufflen,"%s", path);
return TRUE;
}
#include
void main(int argc, char* argv[])
{
printf("%s\n", argv[0]);
}