ReactOS  0.4.12-dev-714-gfaac916
export.c File Reference
#include "precomp.h"
#include <cderr.h>
Include dependency graph for export.c:

Go to the source code of this file.

Functions

static DWORD GetTextFromListView (PMAIN_WND_INFO Info, LPWSTR Text, INT row, INT col)
 
static BOOL SaveServicesToFile (PMAIN_WND_INFO Info, LPCWSTR pszFileName)
 
VOID ExportFile (PMAIN_WND_INFO Info)
 

Function Documentation

◆ ExportFile()

VOID ExportFile ( PMAIN_WND_INFO  Info)

Definition at line 98 of file export.c.

99 {
101  WCHAR szFileName[MAX_PATH];
102 
103  ZeroMemory(&ofn, sizeof(ofn));
104  szFileName[0] = UNICODE_NULL;
105 
106  ofn.lStructSize = sizeof(OPENFILENAME);
107  ofn.hwndOwner = Info->hMainWnd;
108  ofn.lpstrFilter = L"Text (Tab Delimited)(*.txt)\0*.txt\0Text (Comma Delimited)(*.csv)\0*.csv\0";
109  ofn.lpstrFile = szFileName;
111  ofn.lpstrDefExt = L"txt";
113 
114  if(GetSaveFileName(&ofn))
115  {
116  if (SaveServicesToFile(Info, szFileName))
117  return;
118  }
119 
121  MessageBoxW(NULL, L"Export to file failed", NULL, 0);
122 }
#define CDERR_GENERALCODES
Definition: cderr.h:5
#define OFN_EXPLORER
Definition: commdlg.h:104
HWND hwndOwner
Definition: commdlg.h:330
__wchar_t WCHAR
Definition: xmlstorage.h:180
OPENFILENAME ofn
Definition: main.cpp:37
#define ZeroMemory
Definition: winbase.h:1635
LPCSTR lpstrDefExt
Definition: commdlg.h:345
struct TraceInfo Info
DWORD nMaxFile
Definition: commdlg.h:337
#define GetSaveFileName
Definition: commdlg.h:666
#define UNICODE_NULL
smooth NULL
Definition: ftsmooth.c:416
OPENFILENAMEA OPENFILENAME
Definition: commdlg.h:657
#define OFN_PATHMUSTEXIST
Definition: commdlg.h:117
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
static BOOL SaveServicesToFile(PMAIN_WND_INFO Info, LPCWSTR pszFileName)
Definition: export.c:36
#define MAX_PATH
Definition: compat.h:26
DWORD lStructSize
Definition: commdlg.h:329
static const WCHAR L[]
Definition: oid.c:1250
#define OFN_HIDEREADONLY
Definition: commdlg.h:107
LPSTR lpstrFile
Definition: commdlg.h:336
#define OFN_OVERWRITEPROMPT
Definition: commdlg.h:116
LPCSTR lpstrFilter
Definition: commdlg.h:332
DWORD WINAPI CommDlgExtendedError(void)
Definition: cdlg32.c:139
DWORD Flags
Definition: commdlg.h:342

Referenced by MainWndCommand().

◆ GetTextFromListView()

static DWORD GetTextFromListView ( PMAIN_WND_INFO  Info,
LPWSTR  Text,
INT  row,
INT  col 
)
static

Definition at line 15 of file export.c.

19 {
20  LVITEM item;
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 }
#define LVM_GETITEMTEXTW
Definition: commctrl.h:2652
#define ZeroMemory
Definition: winbase.h:1635
struct TraceInfo Info
#define LVIF_TEXT
Definition: commctrl.h:2281
LONG_PTR LPARAM
Definition: windef.h:208
unsigned long DWORD
Definition: ntddk_ex.h:95
static ATOM item
Definition: dde.c:856
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define INT
Definition: msvc.h:26
#define LVITEM
Definition: commctrl.h:2347
char * Text
Definition: combotst.c:136
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:76

Referenced by SaveServicesToFile().

◆ SaveServicesToFile()

static BOOL SaveServicesToFile ( PMAIN_WND_INFO  Info,
LPCWSTR  pszFileName 
)
static

Definition at line 36 of file export.c.

38 {
39  HANDLE hFile;
41 
44  0,
45  NULL,
48  NULL);
49 
51  {
52  WCHAR LVText[500];
53  WCHAR newl[2] = {L'\r', L'\n'};
54  WCHAR tab = L'\t';
55  DWORD dwTextLength, dwWritten;
56  INT NumListedServ = 0;
57  INT i, k;
58 
59  NumListedServ = ListView_GetItemCount(Info->hListView);
60 
61  for (i=0; i < NumListedServ; i++)
62  {
63  for (k=0; k<5; k++)
64  {
65  dwTextLength = GetTextFromListView(Info,
66  LVText,
67  i,
68  k);
69  if (dwTextLength != 0)
70  {
72  LVText,
73  sizeof(WCHAR) * dwTextLength,
74  &dwWritten,
75  NULL);
76 
78  &tab,
79  sizeof(WCHAR),
80  &dwWritten,
81  NULL);
82  }
83  }
85  newl,
86  sizeof(newl),
87  &dwWritten,
88  NULL);
89  }
90 
92  bSuccess = TRUE;
93  }
94 
95  return bSuccess;
96 }
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
int32_t INT
Definition: typedefs.h:56
static BOOLEAN bSuccess
Definition: drive.cpp:417
struct TraceInfo Info
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 GENERIC_WRITE
Definition: nt_native.h:90
WORD WORD PSZ PSZ pszFileName
Definition: vdmdbg.h:41
static DWORD GetTextFromListView(PMAIN_WND_INFO Info, LPWSTR Text, INT row, INT col)
Definition: export.c:15
smooth NULL
Definition: ftsmooth.c:416
#define ListView_GetItemCount(hwnd)
Definition: commctrl.h:2279
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
static const WCHAR L[]
Definition: oid.c:1250
_In_ HANDLE hFile
Definition: mswsock.h:90
#define CREATE_ALWAYS
Definition: disk.h:72
#define CreateFileW
Definition: compat.h:400
int k
Definition: mpi.c:3369

Referenced by ExportFile().