ReactOS 0.4.15-dev-7918-g2a2556c
export.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Services
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: base/applications/mscutils/servman/export.c
5 * PURPOSE: Save services to a file
6 * COPYRIGHT: Copyright 2006 Ged Murphy <gedmurphy@gmail.com>
7 *
8 */
9
10#include "precomp.h"
11
12#include <cderr.h>
13
14static DWORD
17 INT row,
18 INT col)
19{
21 DWORD NumChars;
22
23 ZeroMemory(&item, sizeof(item));
24 item.mask = LVIF_TEXT;
25 item.iSubItem = col;
26 item.pszText = Text;
27 item.cchTextMax = 500;
28 NumChars = (INT)SendMessageW(Info->hListView,
30 row,
31 (LPARAM)&item);
32 return NumChars;
33}
34
35static BOOL
38 DWORD nFormat)
39{
42
43 if (!nFormat || nFormat > 2)
44 {
45 return bSuccess;
46 }
47
50 0,
51 NULL,
54 NULL);
55
57 {
58 WCHAR LVText[500];
59 WCHAR newl[2] = {L'\r', L'\n'};
60 WCHAR seps[2] = {L'\t', L','};
61 DWORD dwTextLength, dwWritten;
62 INT NumListedServ = 0;
63 INT i, k;
64
65 NumListedServ = ListView_GetItemCount(Info->hListView);
66
67 for (i=0; i < NumListedServ; i++)
68 {
69 for (k=0; k < LVMAX; k++)
70 {
71 dwTextLength = GetTextFromListView(Info,
72 LVText,
73 i,
74 k);
75 if (dwTextLength != 0)
76 {
78 LVText,
79 sizeof(WCHAR) * dwTextLength,
80 &dwWritten,
81 NULL);
82 }
83
84 if (k < LVMAX - 1)
85 {
86 /* Do not add separator after the last table cell */
88 &seps[nFormat-1],
89 sizeof(WCHAR),
90 &dwWritten,
91 NULL);
92 }
93 }
95 newl,
96 sizeof(newl),
97 &dwWritten,
98 NULL);
99 }
100
102 bSuccess = TRUE;
103 }
104
105 return bSuccess;
106}
107
109{
111 WCHAR szFileName[MAX_PATH];
112
113 ZeroMemory(&ofn, sizeof(ofn));
114 szFileName[0] = UNICODE_NULL;
115
116 ofn.lStructSize = sizeof(OPENFILENAME);
117 ofn.hwndOwner = Info->hMainWnd;
118 ofn.lpstrFilter = L"Text (Tab Delimited)(*.txt)\0*.txt\0Text (Comma Delimited)(*.csv)\0*.csv\0";
119 ofn.lpstrFile = szFileName;
121 ofn.lpstrDefExt = L"txt";
123
124 if(GetSaveFileName(&ofn))
125 {
126 if (SaveServicesToFile(Info, szFileName, ofn.nFilterIndex))
127 return;
128 }
129
131 MessageBoxW(NULL, L"Export to file failed", NULL, 0);
132}
VOID ExportFile(PMAIN_WND_INFO Info)
Definition: export.c:108
static DWORD GetTextFromListView(PMAIN_WND_INFO Info, LPWSTR Text, INT row, INT col)
Definition: export.c:15
static BOOL SaveServicesToFile(PMAIN_WND_INFO Info, LPCWSTR pszFileName, DWORD nFormat)
Definition: export.c:36
#define LVMAX
Definition: precomp.h:34
#define CDERR_GENERALCODES
Definition: cderr.h:5
DWORD WINAPI CommDlgExtendedError(void)
Definition: cdlg32.c:148
char * Text
Definition: combotst.c:136
#define OFN_OVERWRITEPROMPT
Definition: commdlg.h:116
#define GetSaveFileName
Definition: commdlg.h:666
#define OFN_EXPLORER
Definition: commdlg.h:104
#define OFN_HIDEREADONLY
Definition: commdlg.h:107
#define OFN_PATHMUSTEXIST
Definition: commdlg.h:117
OPENFILENAMEA OPENFILENAME
Definition: commdlg.h:657
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define MAX_PATH
Definition: compat.h:34
#define CreateFileW
Definition: compat.h:741
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
struct png_info_def *typedef unsigned char **typedef struct png_info_def *typedef struct png_info_def *typedef struct png_info_def *typedef unsigned char ** row
Definition: typeof.h:78
static BOOLEAN bSuccess
Definition: drive.cpp:433
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define CREATE_ALWAYS
Definition: disk.h:72
static ATOM item
Definition: dde.c:856
int k
Definition: mpi.c:3369
_In_ HANDLE hFile
Definition: mswsock.h:90
#define GENERIC_WRITE
Definition: nt_native.h:90
#define UNICODE_NULL
#define L(x)
Definition: ntvdm.h:50
#define INT
Definition: polytest.cpp:20
#define ListView_GetItemCount(hwnd)
Definition: commctrl.h:2307
#define LVITEM
Definition: commctrl.h:2375
#define LVM_GETITEMTEXTW
Definition: commctrl.h:2680
#define LVIF_TEXT
Definition: commctrl.h:2309
OPENFILENAME ofn
Definition: sndrec32.cpp:56
LPCSTR lpstrDefExt
Definition: commdlg.h:345
DWORD nFilterIndex
Definition: commdlg.h:335
HWND hwndOwner
Definition: commdlg.h:330
LPSTR lpstrFile
Definition: commdlg.h:336
DWORD Flags
Definition: commdlg.h:342
DWORD lStructSize
Definition: commdlg.h:329
LPCSTR lpstrFilter
Definition: commdlg.h:332
DWORD nMaxFile
Definition: commdlg.h:337
int32_t INT
Definition: typedefs.h:58
WORD WORD PSZ PSZ pszFileName
Definition: vdmdbg.h:44
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690
#define ZeroMemory
Definition: winbase.h:1712
LONG_PTR LPARAM
Definition: windef.h:208
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185