public static string GetHwpFullPathHighest(HwpVersion Version) { int Max = (Version == 0) ? (int)HwpVersion._2010_8 : (int)Version; int Min = (Version == 0) ? (int)HwpVersion._2002_5 - 1 : (int)Version; for (int i = Max; i >= Min; i--) { string FullPath = ""; List <string> aSectionCur = new List <string>(); if (i == Min) { FullPath = GetHwpFullPath(HwpVersion._None_0); } else { FullPath = GetHwpFullPath((HwpVersion)i); } if (!string.IsNullOrEmpty(FullPath)) { return(FullPath); } } return(""); }
/// <summary> /// 아래한글 버전 중 가장 높은 버전을 리턴함. /// </summary> /// <returns></returns> public static HwpVersion GetHwpVersionHighest() { HwpVersion Ver = HwpVersion._None_0; int Max = (int)HwpVersion._2010_8; int Min = (int)HwpVersion._2002_5; for (int i = Max; i >= Min; i--) { string FullPath = GetHwpFullPath((HwpVersion)i); if (!string.IsNullOrEmpty(FullPath)) { return((HwpVersion)i); } } return(Ver); }
private static string GetHwpFullPath(HwpVersion Version) { List <string> aSectionCur = new List <string>(); if (Version == HwpVersion._None_0) { //버전은 알 수 없어도 한글 파일 경로를 리턴하기 위함. aSectionCur.Add(@"Hwp.Document\shell\Open\command"); } else { aSectionCur.Add(@"Hwp.Document." + ((int)Version).ToString() + @"\shell\Open\command"); aSectionCur.Add(@"Hwp.Document." + ((int)Version).ToString() + @"\shell\DefaultIcon"); aSectionCur.Add(@"Hwp.Document." + ((int)Version).ToString() + @"\DefaultIcon"); } for (int j = 0; j < aSectionCur.Count; j++) { object oFullPathCur = CRegistry.GetSetting(HRootKeys.HKEY_CLASSES_ROOT, aSectionCur[j], "", null); if (oFullPathCur == null) { continue; } string FullPathCur = GetExeFullPath((string)oFullPathCur); //HwpView.exe인 경우도 있음. if (FullPathCur.IndexOf("Hwp.exe", StringComparison.CurrentCultureIgnoreCase) == -1) { continue; } if (File.Exists(FullPathCur)) { return(FullPathCur); } } return(string.Empty); }