options.c
上传用户:tuheem
上传日期:2007-05-01
资源大小:21889k
文件大小:29k
源码类别:

多媒体编程

开发平台:

Visual C++

  1. #include "stdafx.h"
  2. #include "globals.h"
  3. #include "CPI_Player.h"
  4. #include "CPI_Playlist.h"
  5. LRESULT CALLBACK
  6. url_windowproc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  7. {
  8.     switch (msg)
  9.     {
  10.     case WM_INITDIALOG:
  11.         return TRUE;
  12.     case WM_CLOSE:
  13.         EndDialog(hwndDlg, 1);
  14.         return TRUE;
  15.     case WM_COMMAND:
  16.         switch (LOWORD(wParam))
  17.         {
  18.         case IDOK:
  19.             {
  20.                 char urlbuf[MAX_PATH];
  21.                 GetDlgItemText(hwndDlg,IDC_URL,urlbuf,MAX_PATH);
  22.                 CPL_Empty(globals.m_hPlaylist);
  23.                 CPL_SyncLoadNextFile(globals.m_hPlaylist);
  24.                 CPL_AddSingleFile(globals.m_hPlaylist, urlbuf, urlbuf);
  25.                 CPL_PlayItem(globals.m_hPlaylist, TRUE, pmCurrentItem);
  26.             }
  27.             EndDialog(hwndDlg, TRUE);
  28.             break;
  29.         case IDCANCEL:
  30.             EndDialog(hwndDlg, TRUE);
  31.             break;
  32.         }
  33.     }
  34.     return FALSE;
  35. }
  36. //
  37. //
  38. //
  39. LRESULT CALLBACK
  40. options_windowproc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  41. {
  42.     switch (msg) {
  43.         /* This message means the dialog is started but not yet visible.
  44.            Do All initializations here
  45.          */
  46.     case WM_INITDIALOG:
  47.         {
  48.             if (options.use_default_skin == TRUE)
  49.                 SendDlgItemMessage(hwndDlg, IDC_PLAYERSKINCHECK,
  50.                                    BM_SETCHECK, BST_UNCHECKED, 0);
  51.             else
  52.                 SendDlgItemMessage(hwndDlg, IDC_PLAYERSKINCHECK,
  53.                                    BM_SETCHECK, BST_CHECKED, 0);
  54.             SendDlgItemMessage(hwndDlg, IDC_EASYMOVE, BM_SETCHECK,
  55.                                options.easy_move, 0);
  56.             SendDlgItemMessage(hwndDlg, IDC_SCROLLTITLE, BM_SETCHECK,
  57.                                options.scroll_track_title, 0);
  58.             SendDlgItemMessage(hwndDlg, IDC_ONTOP, BM_SETCHECK,
  59.                                options.always_on_top, 0);
  60.             SendDlgItemMessage(hwndDlg, IDC_AUTOEXIT, BM_SETCHECK,
  61.                                options.auto_exit_after_playing, 0);
  62.             SendDlgItemMessage(hwndDlg, IDC_REMEMBERPLS, BM_SETCHECK,
  63.                                options.remember_playlist, 0);
  64.             SendDlgItemMessage(hwndDlg, IDC_REMAINING, BM_SETCHECK,
  65.                                options.show_remaining_time, 0);
  66.             SendDlgItemMessage(hwndDlg, IDC_READTAG, BM_SETCHECK,
  67.                                options.read_id3_tag, 0);
  68.             SendDlgItemMessage(hwndDlg, IDC_SUPPORTID3_V2, BM_SETCHECK,
  69.                                options.support_id3v2, 0);
  70.             SendDlgItemMessage(hwndDlg, IDC_PREFERNATIVEOGGTAGS, BM_SETCHECK,
  71.                                options.prefer_native_ogg_tags, 0);
  72.             SendDlgItemMessage(hwndDlg, IDC_READTRACKTIME, BM_SETCHECK,
  73.                                options.work_out_track_lengths, 0);
  74.             SendDlgItemMessage(hwndDlg, IDC_READID3INBACKGROUND, BM_SETCHECK,
  75.                                options.read_id3_tag_in_background, 0);
  76.             SendDlgItemMessage(hwndDlg, IDC_ROTATE, BM_SETCHECK,
  77.                                options.rotate_systray_icon, 0);
  78.             SendDlgItemMessage(hwndDlg, IDC_REMSONG, BM_SETCHECK,
  79.                                options.remember_last_played_track, 0);
  80.             SendDlgItemMessage(hwndDlg, IDC_FILEONCE, BM_SETCHECK,
  81.                                options.allow_file_once_in_playlist, 0);
  82.             SendDlgItemMessage(hwndDlg, IDC_MULTIPLEINSTANCES, BM_SETCHECK,
  83.                                options.allow_multiple_instances, 0);
  84.             SendDlgItemMessage(hwndDlg, IDC_READSELTAG, BM_SETCHECK,
  85.                                options.read_id3_tag_of_selected, 0);
  86.             SendDlgItemMessage(hwndDlg, IDC_AUTOPLAY, BM_SETCHECK,
  87.                                options.auto_play_when_started, 0);
  88.             SendDlgItemMessage(hwndDlg, IDC_TASKBAR, BM_SETCHECK,
  89.                                options.show_on_taskbar, 0);
  90.             SendDlgItemMessage(hwndDlg, IDC_REMEMBERSKIN, UDM_SETRANGE,
  91.                                0, MAKELONG(50, 1));
  92.             SendDlgItemMessage(hwndDlg, IDC_DELAYTIMES, UDM_SETRANGE, 0,
  93.                                MAKELONG(10, 0));
  94.             SetDlgItemInt(hwndDlg, IDC_REMSKINVAL,
  95.                           options.remember_skin_count, FALSE);
  96.             SetDlgItemInt(hwndDlg, IDC_DELAYTIME,
  97.                           options.seconds_delay_after_track, FALSE);
  98.             SetDlgItemText(hwndDlg, IDC_LOADSKIN, options.main_skin_file);
  99.             if (*options.playlist_skin_file)
  100.                 SendDlgItemMessage(hwndDlg, IDC_PLAYLISTSKINCHECK,
  101.                                    BM_SETCHECK, options.use_playlist_skin,
  102.                                    0);
  103.             SendDlgItemMessage(hwndDlg, IDC_MIXER, CB_ADDSTRING, 0, (LPARAM)"System MASTER volume");
  104.             SendDlgItemMessage(hwndDlg, IDC_MIXER, CB_ADDSTRING, 0, (LPARAM)"System WAVE volume");
  105.             SendDlgItemMessage(hwndDlg, IDC_MIXER, CB_ADDSTRING, 0, (LPARAM)"Internal volume");
  106.             if(globals.m_enMixerMode == mmMasterVolume)
  107.                 SendDlgItemMessage(hwndDlg, IDC_MIXER, CB_SETCURSEL, 0, 0);
  108.             else if(globals.m_enMixerMode == mmWaveVolume)
  109.                 SendDlgItemMessage(hwndDlg, IDC_MIXER, CB_SETCURSEL, 1, 0);
  110.             else
  111.                 SendDlgItemMessage(hwndDlg, IDC_MIXER, CB_SETCURSEL, 2, 0);
  112.             CPI_Player__EnumOutputDevices(globals.m_hPlayer);
  113.             globals.m_bOptions_ChangedSkin = FALSE;
  114.             return TRUE;
  115.         }
  116.     case WM_CLOSE:
  117.         EndDialog(hwndDlg, 1);
  118.         return TRUE;
  119.     case WM_COMMAND:
  120.         switch (LOWORD(wParam)) {
  121.         case IDC_SKINBUTTON:
  122.             {
  123.                 OPENFILENAME fn;
  124.                 char    filefilter[] =
  125.                     "CoolPlayer Skin Initialization Files (*.ini)*.iniAll Files (*.*)*.*";
  126.                 BOOL    returnval;
  127.                 char    initialfilename[MAX_PATH * 100] = "";
  128.                 char    pathbuffie[MAX_PATH];
  129.                 strcpy(pathbuffie, options.main_skin_file);
  130.                 path_remove_filespec(pathbuffie);
  131.                 fn.lStructSize = sizeof(OPENFILENAME);
  132.                 fn.hwndOwner = hwndDlg;
  133.                 fn.hInstance = NULL;
  134.                 fn.lpstrFilter = filefilter;
  135.                 fn.lpstrCustomFilter = NULL;
  136.                 fn.nMaxCustFilter = 0;
  137.                 fn.nFilterIndex = 0;
  138.                 fn.lpstrFile = initialfilename;
  139.                 fn.nMaxFile = MAX_PATH * 200;
  140.                 fn.lpstrFileTitle = NULL;
  141.                 fn.nMaxFileTitle = 0;
  142.                 fn.lpstrInitialDir = pathbuffie;
  143.                 fn.lpstrTitle = NULL;
  144.                 fn.Flags =
  145.                     OFN_HIDEREADONLY | OFN_EXPLORER | OFN_FILEMUSTEXIST
  146.                     | OFN_PATHMUSTEXIST | OFN_ENABLESIZING;
  147.                 fn.nFileOffset = 0;
  148.                 fn.nFileExtension = 0;
  149.                 fn.lpstrDefExt = NULL;
  150.                 fn.lCustData = 0;
  151.                 fn.lpfnHook = NULL;
  152.                 fn.lpTemplateName = NULL;
  153.                 returnval = GetOpenFileName(&fn);
  154.                 if (returnval != FALSE) {
  155.                     char    pathbuf[MAX_PATH] = "";
  156.                     SetDlgItemText(hwndDlg, IDC_LOADSKIN, fn.lpstrFile);
  157.                     SendDlgItemMessage(hwndDlg, IDC_PLAYERSKINCHECK,
  158.                                        BM_SETCHECK, BST_CHECKED, 0);
  159.                     globals.m_bOptions_ChangedSkin = TRUE;
  160.                 }
  161.                 break;
  162.             }
  163.         case IDC_FLUSH_SKINLIST:
  164.             {
  165.                 int     itemcounter =
  166.                     GetMenuItemCount(GetSubMenu
  167.                                      (globals.main_menu_popup, 4));
  168.                 int     teller;
  169.                 for (teller = 0; teller < itemcounter - 1; teller++) {
  170.                     RemoveMenu(GetSubMenu(globals.main_menu_popup, 4), 0,
  171.                                MF_BYPOSITION);
  172.                 }
  173.             }
  174.             break;
  175.         case IDCANCEL:
  176.             EndDialog(hwndDlg, 1);
  177.             break;
  178.         case IDOK:
  179.             {
  180.                 BOOL    duplicatesalreadyremoved =
  181.                     options.allow_file_once_in_playlist;
  182.                 int     index;
  183.                 HWND    hWnd = GetParent(hwndDlg);
  184.                 BOOL bSkinChosen;
  185.                 options.auto_exit_after_playing =
  186.                     SendDlgItemMessage(hwndDlg, IDC_AUTOEXIT, BM_GETCHECK,
  187.                                        0, 0);
  188.                 options.remember_playlist =
  189.                     SendDlgItemMessage(hwndDlg, IDC_REMEMBERPLS,
  190.                                        BM_GETCHECK, 0, 0);
  191.                 options.show_remaining_time =
  192.                     SendDlgItemMessage(hwndDlg, IDC_REMAINING, BM_GETCHECK,
  193.                                        0, 0);
  194.                 options.read_id3_tag =
  195.                     SendDlgItemMessage(hwndDlg, IDC_READTAG, BM_GETCHECK,
  196.                                        0, 0);
  197.                 options.support_id3v2 =
  198.                     SendDlgItemMessage(hwndDlg, IDC_SUPPORTID3_V2, BM_GETCHECK,
  199.                                        0, 0);
  200.                 options.prefer_native_ogg_tags =
  201.                     SendDlgItemMessage(hwndDlg, IDC_PREFERNATIVEOGGTAGS, BM_GETCHECK,
  202.                                        0, 0);
  203.                 options.read_id3_tag_in_background =
  204.                     SendDlgItemMessage(hwndDlg, IDC_READID3INBACKGROUND, BM_GETCHECK,
  205.                                        0, 0);
  206.                 options.work_out_track_lengths =
  207.                     SendDlgItemMessage(hwndDlg, IDC_READTRACKTIME, BM_GETCHECK,
  208.                                        0, 0);
  209.                 options.easy_move =
  210.                     SendDlgItemMessage(hwndDlg, IDC_EASYMOVE, BM_GETCHECK,
  211.                                        0, 0);
  212.                 options.rotate_systray_icon =
  213.                     SendDlgItemMessage(hwndDlg, IDC_ROTATE, BM_GETCHECK, 0,
  214.                                        0);
  215.                 options.allow_file_once_in_playlist =
  216.                     SendDlgItemMessage(hwndDlg, IDC_FILEONCE, BM_GETCHECK,
  217.                                        0, 0);
  218.                 options.allow_multiple_instances =
  219.                     SendDlgItemMessage(hwndDlg, IDC_MULTIPLEINSTANCES, BM_GETCHECK,
  220.                                        0, 0);
  221.                 options.read_id3_tag_of_selected =
  222.                     SendDlgItemMessage(hwndDlg, IDC_READSELTAG,
  223.                                        BM_GETCHECK, 0, 0);
  224.                 options.auto_play_when_started =
  225.                     SendDlgItemMessage(hwndDlg, IDC_AUTOPLAY, BM_GETCHECK,
  226.                                        0, 0);
  227.                 options.show_on_taskbar =
  228.                     SendDlgItemMessage(hwndDlg, IDC_TASKBAR, BM_GETCHECK,
  229.                                        0, 0);
  230.                 if (options.show_on_taskbar) {
  231.                     SetWindowLong(hWnd, GWL_EXSTYLE,
  232.                                   GetWindowLong(hWnd,
  233.                                                 GWL_EXSTYLE) &
  234.                                   ~WS_EX_TOOLWINDOW);
  235.                     SetWindowLong(hWnd, GWL_STYLE,
  236.                                   GetWindowLong(hWnd,
  237.                                                 GWL_STYLE) | WS_SYSMENU);
  238.                 } else {
  239.                     ShowWindow(hWnd, SW_HIDE);
  240.                     SetWindowLong(hWnd, GWL_EXSTYLE,
  241.                                   GetWindowLong(hWnd,
  242.                                                 GWL_EXSTYLE) |
  243.                                   WS_EX_TOOLWINDOW);
  244.                     SetWindowLong(hWnd, GWL_STYLE,
  245.                                   GetWindowLong(hWnd,
  246.                                                 GWL_STYLE) | WS_SYSMENU);
  247.                     ShowWindow(hWnd, SW_SHOW);
  248.                 }
  249.                 options.remember_last_played_track =
  250.                     SendDlgItemMessage(hwndDlg, IDC_REMSONG, BM_GETCHECK,
  251.                                        0, 0);
  252.                 options.remember_skin_count =
  253.                     GetDlgItemInt(hwndDlg, IDC_REMSKINVAL, NULL, FALSE);
  254.                 options.seconds_delay_after_track =
  255.                     GetDlgItemInt(hwndDlg, IDC_DELAYTIME, NULL, FALSE);
  256.                 options.scroll_track_title =
  257.                     SendDlgItemMessage(hwndDlg, IDC_SCROLLTITLE,
  258.                                        BM_GETCHECK, 0, 0);
  259.                 options.always_on_top =
  260.                     SendDlgItemMessage(hwndDlg, IDC_ONTOP, BM_GETCHECK, 0,
  261.                                        0);
  262.                 window_set_always_on_top(hWnd, options.always_on_top);
  263.                 GetDlgItemText(hwndDlg, IDC_LOADSKIN,
  264.                                options.main_skin_file, MAX_PATH);
  265.                 bSkinChosen = SendDlgItemMessage(hwndDlg, IDC_PLAYERSKINCHECK, BM_GETCHECK, 0, 0);
  266.                 if(bSkinChosen != !options.use_default_skin
  267.                         || globals.m_bOptions_ChangedSkin == TRUE)
  268.                 {
  269.                     options.use_default_skin = !bSkinChosen;
  270.                     globals.main_bool_skin_next_is_default = options.use_default_skin;
  271.                     globals.playlist_bool_force_skin_from_options = TRUE;
  272.                     main_play_control(ID_LOADSKIN, hWnd);
  273.                 }
  274.                 index = SendDlgItemMessage(hwndDlg, IDC_OUTPUT, CB_GETCURSEL, 0, 0);
  275.                 if (options.decoder_output_mode != index)
  276.                 {
  277.                     options.decoder_output_mode = index;
  278.                     CPI_Player__OnOutputDeviceChange(globals.m_hPlayer);
  279.                 }
  280.                 // Mixer control
  281.                 {
  282.                     int iMixerSelection;
  283.                     CPe_MixerMode enNewMixerMode;
  284.                     iMixerSelection = SendDlgItemMessage(hwndDlg, IDC_MIXER, CB_GETCURSEL, 0, 0);
  285.                     if(iMixerSelection == 0)
  286.                         enNewMixerMode = mmMasterVolume;
  287.                     else if(iMixerSelection == 1)
  288.                         enNewMixerMode = mmWaveVolume;
  289.                     else
  290.                         enNewMixerMode = mmInternal;
  291.                     if(enNewMixerMode != globals.m_enMixerMode)
  292.                     {
  293.                         // Change mixer
  294.                         globals.m_enMixerMode = enNewMixerMode;
  295.                         CPI_Player__ReopenMixer(globals.m_hPlayer);
  296.                         // Setup UI
  297.                         if(enNewMixerMode == mmInternal)
  298.                             globals.m_iVolume = 100;
  299.                         else
  300.                             globals.m_iVolume = CPI_Player__GetVolume(globals.m_hPlayer);
  301.                         main_draw_vu_from_value(windows.wnd_main, VolumeSlider, globals.m_iVolume);
  302.                     }
  303.                 }
  304.                 if(!duplicatesalreadyremoved && options.allow_file_once_in_playlist)
  305.                     CPL_RemoveDuplicates(globals.m_hPlaylist);
  306.                 EndDialog(hwndDlg, 1);
  307.                 break;
  308.             }
  309.         case IDC_ONTOP:
  310.             break;
  311.         case IDC_REGFILETYPE:
  312.             {
  313.                 HKEY    result;
  314.                 DWORD   lpdwDisposition;
  315.                 char    pathbuf[MAX_PATH];
  316.                 char    stringval[MAX_PATH + 3];
  317.                 CPI_Player__AssociateFileExtensions(globals.m_hPlayer);
  318.                 GetModuleFileName(NULL, pathbuf, MAX_PATH);
  319.                 sprintf(stringval, "%s,%1d", pathbuf, 1);
  320.                 RegCreateKeyEx(HKEY_CLASSES_ROOT, CIC_COOLPLAYER_FILETYPE,
  321.                                0, NULL, REG_OPTION_NON_VOLATILE,
  322.                                KEY_ALL_ACCESS, NULL, &result,
  323.                                &lpdwDisposition);
  324.                 RegSetValueEx(result, NULL, 0, REG_SZ,
  325.                               CIC_COOLPLAYER_FILEDESC, sizeof(CIC_COOLPLAYER_FILEDESC));
  326.                 RegCloseKey(result);
  327.                 RegCreateKeyEx(HKEY_CLASSES_ROOT,
  328.                                CIC_COOLPLAYER_FILETYPE "\DefaultIcon",
  329.                                0, NULL, REG_OPTION_NON_VOLATILE,
  330.                                KEY_ALL_ACCESS, NULL, &result,
  331.                                &lpdwDisposition);
  332.                 RegSetValueEx(result, NULL, 0, REG_SZ, stringval,
  333.                               strlen(stringval) + 1);
  334.                 RegCloseKey(result);
  335.                 RegCreateKeyEx(HKEY_CLASSES_ROOT,
  336.                                CIC_COOLPLAYER_FILETYPE "\Shell", 0,
  337.                                NULL, REG_OPTION_NON_VOLATILE,
  338.                                KEY_ALL_ACCESS, NULL, &result,
  339.                                &lpdwDisposition);
  340.                 RegCloseKey(result);
  341.                 RegCreateKeyEx(HKEY_CLASSES_ROOT,
  342.                                CIC_COOLPLAYER_FILETYPE "\Shell\Open",
  343.                                0, NULL, REG_OPTION_NON_VOLATILE,
  344.                                KEY_ALL_ACCESS, NULL, &result,
  345.                                &lpdwDisposition);
  346.                 RegCloseKey(result);
  347.                 RegCreateKeyEx(HKEY_CLASSES_ROOT,
  348.                                CIC_COOLPLAYER_FILETYPE "\Shell\Open\command",
  349.                                0, NULL, REG_OPTION_NON_VOLATILE,
  350.                                KEY_ALL_ACCESS, NULL, &result,
  351.                                &lpdwDisposition);
  352.                 sprintf(stringval, ""%s" "%%1"", pathbuf);
  353.                 RegSetValueEx(result, NULL, 0, REG_SZ, stringval,
  354.                               strlen(stringval) + 1);
  355.                 RegCloseKey(result);
  356.                 RegCreateKeyEx(HKEY_CLASSES_ROOT,
  357.                                CIC_COOLPLAYER_FILETYPE "\Shell\CoolPlayer Queue",
  358.                                0, NULL, REG_OPTION_NON_VOLATILE,
  359.                                KEY_ALL_ACCESS, NULL, &result,
  360.                                &lpdwDisposition);
  361.                 RegCloseKey(result);
  362.                 RegCreateKeyEx(HKEY_CLASSES_ROOT,
  363.                                CIC_COOLPLAYER_FILETYPE "\Shell\CoolPlayer Queue\command",
  364.                                0, NULL, REG_OPTION_NON_VOLATILE,
  365.                                KEY_ALL_ACCESS, NULL, &result,
  366.                                &lpdwDisposition);
  367.                 sprintf(stringval, ""%s" "%%1" -add", pathbuf);
  368.                 RegSetValueEx(result, NULL, 0, REG_SZ, stringval,
  369.                               strlen(stringval) + 1);
  370.                 RegCloseKey(result);
  371.                 RegCreateKeyEx(HKEY_CLASSES_ROOT,
  372.                                CIC_COOLPLAYER_FILETYPE "\Shell\CoolPlayer Play",
  373.                                0, NULL, REG_OPTION_NON_VOLATILE,
  374.                                KEY_ALL_ACCESS, NULL, &result,
  375.                                &lpdwDisposition);
  376.                 RegCloseKey(result);
  377.                 RegCreateKeyEx(HKEY_CLASSES_ROOT,
  378.                                CIC_COOLPLAYER_FILETYPE "\Shell\CoolPlayer Play\command",
  379.                                0, NULL, REG_OPTION_NON_VOLATILE,
  380.                                KEY_ALL_ACCESS, NULL, &result,
  381.                                &lpdwDisposition);
  382.                 sprintf(stringval, ""%s" "%%1"", pathbuf);
  383.                 RegSetValueEx(result, NULL, 0, REG_SZ, stringval,
  384.                               strlen(stringval) + 1);
  385.                 RegCloseKey(result);
  386.                 RegCreateKeyEx(HKEY_CLASSES_ROOT, ".m3u", 0, NULL,
  387.                                REG_OPTION_NON_VOLATILE,
  388.                                KEY_ALL_ACCESS, NULL, &result,
  389.                                &lpdwDisposition);
  390.                 RegSetValueEx(result, NULL, 0, REG_SZ,
  391.                               CIC_COOLPLAYER_PLAYLISTFILETYPE, sizeof(CIC_COOLPLAYER_PLAYLISTFILETYPE));
  392.                 RegCloseKey(result);
  393.                 RegCreateKeyEx(HKEY_CLASSES_ROOT, ".pls", 0, NULL,
  394.                                REG_OPTION_NON_VOLATILE,
  395.                                KEY_ALL_ACCESS, NULL, &result,
  396.                                &lpdwDisposition);
  397.                 RegSetValueEx(result, NULL, 0, REG_SZ,
  398.                               CIC_COOLPLAYER_PLAYLISTFILETYPE, sizeof(CIC_COOLPLAYER_PLAYLISTFILETYPE));
  399.                 RegCloseKey(result);
  400.                 RegCreateKeyEx(HKEY_CLASSES_ROOT, CIC_COOLPLAYER_PLAYLISTFILETYPE,
  401.                                0, NULL, REG_OPTION_NON_VOLATILE,
  402.                                KEY_ALL_ACCESS, NULL, &result,
  403.                                &lpdwDisposition);
  404.                 RegSetValueEx(result, NULL, 0, REG_SZ,
  405.                               CIC_COOLPLAYER_PLAYLISTFILEDESC, sizeof(CIC_COOLPLAYER_PLAYLISTFILEDESC));
  406.                 RegCloseKey(result);
  407.                 RegCreateKeyEx(HKEY_CLASSES_ROOT,
  408.                                CIC_COOLPLAYER_PLAYLISTFILETYPE "\DefaultIcon",
  409.                                0, NULL, REG_OPTION_NON_VOLATILE,
  410.                                KEY_ALL_ACCESS, NULL, &result,
  411.                                &lpdwDisposition);
  412.                 sprintf(stringval, "%s,%d", pathbuf, 2);
  413.                 RegSetValueEx(result, NULL, 0, REG_SZ, stringval,
  414.                               strlen(stringval) + 1);
  415.                 RegCloseKey(result);
  416.                 RegCreateKeyEx(HKEY_CLASSES_ROOT,
  417.                                CIC_COOLPLAYER_PLAYLISTFILETYPE "\Shell", 0,
  418.                                NULL, REG_OPTION_NON_VOLATILE,
  419.                                KEY_ALL_ACCESS, NULL, &result,
  420.                                &lpdwDisposition);
  421.                 RegCloseKey(result);
  422.                 RegCreateKeyEx(HKEY_CLASSES_ROOT,
  423.                                CIC_COOLPLAYER_PLAYLISTFILETYPE "\Shell\Open",
  424.                                0, NULL, REG_OPTION_NON_VOLATILE,
  425.                                KEY_ALL_ACCESS, NULL, &result,
  426.                                &lpdwDisposition);
  427.                 RegCloseKey(result);
  428.                 RegCreateKeyEx(HKEY_CLASSES_ROOT,
  429.                                CIC_COOLPLAYER_PLAYLISTFILETYPE "\Shell\Open\command",
  430.                                0, NULL, REG_OPTION_NON_VOLATILE,
  431.                                KEY_ALL_ACCESS, NULL, &result,
  432.                                &lpdwDisposition);
  433.                 sprintf(stringval, ""%s" "%%1"", pathbuf);
  434.                 RegSetValueEx(result, NULL, 0, REG_SZ, stringval,
  435.                               strlen(stringval) + 1);
  436.                 RegCloseKey(result);
  437.                 RegCreateKeyEx(HKEY_CLASSES_ROOT,
  438.                                CIC_COOLPLAYER_PLAYLISTFILETYPE "\Shell\CoolPlayer Queue",
  439.                                0, NULL, REG_OPTION_NON_VOLATILE,
  440.                                KEY_ALL_ACCESS, NULL, &result,
  441.                                &lpdwDisposition);
  442.                 RegCloseKey(result);
  443.                 RegCreateKeyEx(HKEY_CLASSES_ROOT,
  444.                                CIC_COOLPLAYER_PLAYLISTFILETYPE "\Shell\CoolPlayer Queue\command",
  445.                                0, NULL, REG_OPTION_NON_VOLATILE,
  446.                                KEY_ALL_ACCESS, NULL, &result,
  447.                                &lpdwDisposition);
  448.                 sprintf(stringval, ""%s" "%%1" -add", pathbuf);
  449.                 RegSetValueEx(result, NULL, 0, REG_SZ, stringval,
  450.                               strlen(stringval) + 1);
  451.                 RegCloseKey(result);
  452.                 RegCreateKeyEx(HKEY_CLASSES_ROOT,
  453.                                CIC_COOLPLAYER_PLAYLISTFILETYPE "\Shell\CoolPlayer Play",
  454.                                0, NULL, REG_OPTION_NON_VOLATILE,
  455.                                KEY_ALL_ACCESS, NULL, &result,
  456.                                &lpdwDisposition);
  457.                 RegCloseKey(result);
  458.                 RegCreateKeyEx(HKEY_CLASSES_ROOT,
  459.                                CIC_COOLPLAYER_PLAYLISTFILETYPE "\Shell\CoolPlayer Play\command",
  460.                                0, NULL, REG_OPTION_NON_VOLATILE,
  461.                                KEY_ALL_ACCESS, NULL, &result,
  462.                                &lpdwDisposition);
  463.                 sprintf(stringval, ""%s" "%%1"", pathbuf);
  464.                 RegSetValueEx(result, NULL, 0, REG_SZ, stringval,
  465.                               strlen(stringval) + 1);
  466.                 RegCloseKey(result);
  467.                 // Folder handlers
  468.                 RegCreateKeyEx(HKEY_CLASSES_ROOT,
  469.                                "Folder\Shell\CoolPlayer Play",
  470.                                0, NULL, REG_OPTION_NON_VOLATILE,
  471.                                KEY_ALL_ACCESS, NULL, &result,
  472.                                &lpdwDisposition);
  473.                 RegCloseKey(result);
  474.                 RegCreateKeyEx(HKEY_CLASSES_ROOT,
  475.                                "Folder\Shell\CoolPlayer Play\command",
  476.                                0, NULL, REG_OPTION_NON_VOLATILE,
  477.                                KEY_ALL_ACCESS, NULL, &result,
  478.                                &lpdwDisposition);
  479.                 sprintf(stringval, ""%s" "%%1"", pathbuf);
  480.                 RegSetValueEx(result, NULL, 0, REG_SZ, stringval,
  481.                               strlen(stringval) + 1);
  482.                 RegCloseKey(result);
  483.                 RegCreateKeyEx(HKEY_CLASSES_ROOT,
  484.                                "Folder\Shell\CoolPlayer Queue\command",
  485.                                0, NULL, REG_OPTION_NON_VOLATILE,
  486.                                KEY_ALL_ACCESS, NULL, &result,
  487.                                &lpdwDisposition);
  488.                 sprintf(stringval, ""%s" "%%1" -add", pathbuf);
  489.                 RegSetValueEx(result, NULL, 0, REG_SZ, stringval,
  490.                               strlen(stringval) + 1);
  491.                 RegCloseKey(result);
  492.                 RegDeleteKey(HKEY_CLASSES_ROOT, CIC_COOLPLAYER_FILETYPE "\Shell\Enqueue in CoolPlayer\command");
  493.                 RegDeleteKey(HKEY_CLASSES_ROOT, CIC_COOLPLAYER_FILETYPE "\Shell\Enqueue in CoolPlayer\");
  494.                 RegDeleteKey(HKEY_CLASSES_ROOT, CIC_COOLPLAYER_PLAYLISTFILETYPE "\Shell\Enqueue in CoolPlayer\command");
  495.                 RegDeleteKey(HKEY_CLASSES_ROOT, CIC_COOLPLAYER_PLAYLISTFILETYPE "\Shell\Enqueue in CoolPlayer\");
  496.                 MessageBox(hwndDlg,
  497.                            "Filetypes are registered.nYou can doubleclick a supported file to run CoolPlayer.",
  498.                            "CoolPlayer", MB_ICONINFORMATION);
  499.                 break;
  500.             }
  501.         case IDC_ADDICONS:
  502.             {
  503.                 char    pathname[MAX_PATH];
  504.                 char    startmenu[MAX_PATH];
  505.                 char    linkname[MAX_PATH];
  506.                 char    linkname2[MAX_PATH];
  507.                 LPITEMIDLIST ppidl;
  508.                 int     buflen = MAX_PATH;
  509.                 long    vartype = REG_SZ;
  510.                 GetModuleFileName(NULL, pathname, MAX_PATH);
  511.                 CoInitialize(NULL);
  512.                 SHGetSpecialFolderLocation(hwndDlg, CSIDL_STARTMENU,
  513.                                            &ppidl);
  514.                 SHGetPathFromIDList(ppidl, startmenu);
  515.                 sprintf(linkname, "%s\CoolPlayer.lnk", startmenu);
  516.                 ExpandEnvironmentStrings(linkname, // pointer to string with environment variables
  517.                                          linkname2, // pointer to string with expanded environment
  518.                                          // variables
  519.                                          MAX_PATH);
  520.                 path_create_link(pathname, linkname2, NULL);
  521.                 SHGetSpecialFolderLocation(hwndDlg, CSIDL_DESKTOP, &ppidl);
  522.                 SHGetPathFromIDList(ppidl, startmenu);
  523.                 sprintf(linkname, "%s\CoolPlayer.lnk", startmenu);
  524.                 ExpandEnvironmentStrings(linkname, // pointer to string with environment variables
  525.                                          linkname2, // pointer to string with expanded environment
  526.                                          // variables
  527.                                          MAX_PATH);
  528.                 path_create_link(pathname, linkname2, NULL);
  529.                 CoUninitialize();
  530.                 MessageBox(hwndDlg,
  531.                            "An icon for CoolPlayer has been created in the StartMenu and Desktop.",
  532.                            "CoolPlayer", MB_ICONINFORMATION);
  533.                 break;
  534.             }
  535.         }
  536.         switch (HIWORD(wParam)) {
  537.         case CBN_SELENDOK:
  538.             {
  539.                 break;
  540.             }
  541.         }
  542.     }
  543.     return FALSE;
  544. }
  545. BOOL    window_set_always_on_top(HWND hWnd, BOOL yes)
  546. {
  547.     if (yes) {
  548.         SetWindowPos(hWnd, // handle to window
  549.                      HWND_TOPMOST, // placement-order handle
  550.                      0, // horizontal position
  551.                      0, // vertical position
  552.                      0, // width
  553.                      0, // height
  554.                      SWP_NOMOVE | SWP_NOSIZE); // window-positioning flags
  555.     } else {
  556.         SetWindowPos(hWnd, // handle to window
  557.                      HWND_NOTOPMOST, // placement-order handle
  558.                      0, // horizontal position
  559.                      0, // vertical position
  560.                      0, // width
  561.                      0, // height
  562.                      SWP_NOMOVE | SWP_NOSIZE); // window-positioning flags
  563.     }
  564.     return TRUE;
  565. }