2 * PROJECT: ReactOS Services
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: base/system/servman/export.c
5 * PURPOSE: Save services to a file
6 * COPYRIGHT: Copyright 2006 Ged Murphy <gedmurphy@gmail.com>
16 GetTextFromListView(PMAIN_WND_INFO Info
,
24 ZeroMemory(&item
, sizeof(item
));
25 item
.mask
= LVIF_TEXT
;
28 item
.cchTextMax
= 500;
29 NumChars
= (INT
)SendMessage(Info
->hListView
,
38 SaveServicesToFile(PMAIN_WND_INFO Info
,
42 BOOL bSuccess
= FALSE
;
44 hFile
= CreateFile(pszFileName
,
49 FILE_ATTRIBUTE_NORMAL
,
52 if(hFile
!= INVALID_HANDLE_VALUE
)
55 TCHAR newl
[2] = {_T('\r'), _T('\n')};
57 DWORD dwTextLength
, dwWritten
;
58 INT NumListedServ
= 0;
61 NumListedServ
= ListView_GetItemCount(Info
->hListView
);
63 for (i
=0; i
< NumListedServ
; i
++)
67 dwTextLength
= GetTextFromListView(Info
,
71 if (dwTextLength
!= 0)
75 sizeof(TCHAR
) * dwTextLength
,
100 VOID
ExportFile(PMAIN_WND_INFO Info
)
103 TCHAR szFileName
[MAX_PATH
] = _T("");
105 ZeroMemory(&ofn
, sizeof(ofn
));
107 ofn
.lStructSize
= sizeof(OPENFILENAME
);
108 ofn
.hwndOwner
= Info
->hMainWnd
;
109 ofn
.lpstrFilter
= _T("Text (Tab Delimited)(*.txt)\0*.txt\0Text (Comma Delimited)(*.csv)\0*.csv\0");
110 ofn
.lpstrFile
= szFileName
;
111 ofn
.nMaxFile
= MAX_PATH
;
112 ofn
.lpstrDefExt
= _T("txt");
113 ofn
.Flags
= OFN_EXPLORER
| OFN_PATHMUSTEXIST
| OFN_HIDEREADONLY
| OFN_OVERWRITEPROMPT
;
115 if(GetSaveFileName(&ofn
))
117 if (SaveServicesToFile(Info
, szFileName
))
121 if (CommDlgExtendedError() != CDERR_GENERALCODES
)
122 MessageBox(NULL
, _T("Export to file failed"), NULL
, 0);