Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Please help.Finding application path:((

AsAdiAsAdi Member Posts: 117
Hi there
it seems stupid problem,does it?Actually I need open a database in my program,and I want place this database file in the application folder,and I want the defaulth value of my member class m_dbPath becomes the applicaiton path,but I couldn't find any function in SDK or MFC which return any string as application path.I saw CDocument::GetPathName and CDocument::SetPathName,but they can't help me,becaue GetPathName doesn't return application path automatically.Please help me and let me know how can I find application path using MFC or Windows SDK in Visual C++ 6.0

Thanks in advanced
Reza AsAdi

Comments

  • nmgnmg Member Posts: 4
    : Hi there
    : it seems stupid problem,does it?Actually I need open a database in my program,and I want place this database file in the application folder,and I want the defaulth value of my member class m_dbPath becomes the applicaiton path,but I couldn't find any function in SDK or MFC which return any string as application path.I saw CDocument::GetPathName and CDocument::SetPathName,but they can't help me,becaue GetPathName doesn't return application path automatically.Please help me and let me know how can I find application path using MFC or Windows SDK in Visual C++ 6.0
    :
    : Thanks in advanced
    : Reza AsAdi
    :

    Try API ::GetModuleFileName(...)


  • AsAdiAsAdi Member Posts: 117
    : : Hi there
    : : it seems stupid problem,does it?Actually I need open a database in my program,and I want place this database file in the application folder,and I want the defaulth value of my member class m_dbPath becomes the applicaiton path,but I couldn't find any function in SDK or MFC which return any string as application path.I saw CDocument::GetPathName and CDocument::SetPathName,but they can't help me,becaue GetPathName doesn't return application path automatically.Please help me and let me know how can I find application path using MFC or Windows SDK in Visual C++ 6.0
    : :
    : : Thanks in advanced
    : : Reza AsAdi
    : :
    :
    : Try API ::GetModuleFileName(...)
    :
    :
    :
    It worked correctly,million Thanks :))
    Best Regards
    Reza AsAdi
  • TheSunGodTheSunGod Member Posts: 8
    Most eficient and easy is to use

    DWORD GetCurrentDirectory(
    DWORD nBufferLength, // size of directory buffer
    LPTSTR lpBuffer // directory buffer
    );
  • AsmGuru62AsmGuru62 Member Posts: 6,519
  • AsAdiAsAdi Member Posts: 117
    :
    :
    Hi there,
    Actually I had some network problems at home,so I've been some late.
    Dear Asm,may you tell why it may not return the correct dir?and so,how can I find my application path in MFC based application?

    Thanks in advance
    AsAdi
  • AsmGuru62AsmGuru62 Member Posts: 6,519
    : :
    : :
    : Hi there,
    : Actually I had some network problems at home,so I've been some late.
    : Dear Asm,may you tell why it may not return the correct dir?and so,how can I find my application path in MFC based application?
    :
    : Thanks in advance
    : AsAdi
    :
    [blue]Someone suggested [b]GetModuleFileName()[/b] - that is the correct way - did you try it?[/blue]
  • AsAdiAsAdi Member Posts: 117
    Thanks all kind people,GetModuleFileName() works correctly!!!
    : : :
    : : :
    : : Hi there,
    : : Actually I had some network problems at home,so I've been some late.
    : : Dear Asm,may you tell why it may not return the correct dir?and so,how can I find my application path in MFC based application?
    : :
    : : Thanks in advance
    : : AsAdi
    : :
    : [blue]Someone suggested [b]GetModuleFileName()[/b] - that is the correct way - did you try it?[/blue]
    :

Sign In or Register to comment.