MFC ACTIVEX中可以使用相对路径来找文件吗?解决办法

MFC ACTIVEX中可以使用相对路径来找文件吗?
举例如下:在某一个目录下有OCX和CONFIG两个目录,如下所示。
OCX-----ocTest.ocx
CONFIG-----Config.ini 

在ocTest.ocx的程序中想要取得Config.ini中的内容,可以使用“..\\CONFIG\\Config.ini”吗?我目前在程序中使用了,却找不到这个文件,使用绝对路径就没有问题,是什么原因呢?是不是他寻找路径的方法不一样?
------解决思路----------------------
前面先调用SetCurrentDirectory()设置一下,然后再试试。
------解决思路----------------------
因为当前目录不知道是啥
------解决思路----------------------
GetFullPathName
The GetFullPathName function retrieves the full path and filename of a specified file. 

DWORD GetFullPathName(
  LPCTSTR lpFileName,  // pointer to name of file to find path for
  DWORD nBufferLength, // size, in characters, of path buffer
  LPTSTR lpBuffer,     // pointer to path buffer
  LPTSTR *lpFilePart   // pointer to filename in path
);
 
Parameters
lpFileName 
Pointer to a null-terminated string that specifies a valid filename. This string can use either short (the 8.3 form) or long filenames. 
nBufferLength 
Specifies the size, in characters, of the buffer for the drive and path. 
lpBuffer 
Pointer to a buffer that contains the null-terminated string for the name of the drive and path. 
lpFilePart 
Pointer to a variable that receives the address (in lpBuffer) of the final filename component in the path. 
Return Values
If the GetFullPathName function succeeds, the return value is the length, in characters, of the string copied to lpBuffer, not including the terminating null character. 

If the lpBuffer buffer is too small, the return value is the size of the buffer, in characters, required to hold the path. 

If the function fails, the return value is zero. To get extended error information, call GetLastError. 

Remarks
The GetFullPathName function merges the name of the current drive and directory with the specified filename to determine the full path and filename of the specified file. It also calculates the address of the filename portion of the full path and filename. This function does not verify that the resulting path and filename are valid or that they refer to an existing file on the associated volume. 

QuickInfo
  Windows NT: Requires version 3.1 or later.
  Windows: Requires Windows 95 or later.
  Windows CE: Unsupported.
  Header: Declared in winbase.h.
  Import Library: Use kernel32.lib.
  Unicode: Implemented as Unicode and ANSI versions on Windows NT.

See Also
File I/O Overview, File Functions, GetShortPathName, GetTempPath, SearchPath

 

------解决思路----------------------
当前目录随时可以变的,比如文件对话框会改当前目录。用exe路径也不靠谱,因为你的控件可能是在Visual Studio里面创建。

应该用ocx自己的目录(GetModuleFileName reinterpret_cast<HINSTANCE>(&__ImageBase))
------解决思路----------------------
 CHAR pbuf[MAX_PATH]; //存放路径的变量
 GetModuleFileName(NULL,pbuf,MAX_PATH); //获取程序的当前路径
 *strrchr(pbuf,'\\')=0; //截取到文件路径(斜杠换为0)
 strcat(pbuf,"\\j_mj_cfg.ini"); //组合出配置的绝对路径