|
char szExecutable[FILENAME_MAX];
String strFullPath;
String strFileName;
int nResult;
strFileName = "C:\\Work\\AAA.HWP";
nResult = (int)FindExecutable(strFileName.c_str(), NULL, (LPTSTR)&szExecutable);
strFullPath = ExtractShortPathName((AnsiString)szExecutable) + " " + ExtractShortPathName(m_strFileName);
if(nResult == 31) // 연결된 실행 파일이 없음
// 에러 처리
ShowMessage("연결된 프로그램이 없습니다.");
if(nResult >= 32 ) // 연결된 실행 파일이 있음
// 작업 수행
ShowMessage(strFullPath);
김재구 님이 쓰신 글 :
: /*
: 저 자신 윈도우 프로그래밍에는 초짜라서 이방법이 정석인지는 모르겠군요.
: 데브피아에서 레지스트리를 읽는다는 답변을 본적이 있어서 그걸 빌더
: 코드로 만들어봤습니다. */
:
:
: AnsiString GetPathFromExt(AnsiString Ext)
: {
: AnsiString Path;
: TRegistry *Reg=new TRegistry();
: Reg->RootKey=HKEY_CLASSES_ROOT;
: Reg->OpenKey(Ext,false);
: Path=Reg->ReadString("");
: Path=Path + "\\shell\\open\\command";
: Reg->CloseKey();
: Reg->OpenKey(Path,false);
: Path=Reg->ReadString("");
: Path=Path.Delete(Path.Pos("\%1")-3,Path.Length());
: TReplaceFlags rf;
: rf<<rfReplaceAll;
: Path=StringReplace(Path,"\"","",rf);
: Reg->CloseKey();
: delete Reg;
: return Path;
: }
:
:
: void __fastcall TForm1::Button1Click(TObject *Sender)
: {
: ShowMessage(GetPathFromExt(".pdf"));
:
: }
:
:
|