+
+static void get_crashdump_path(wchar_t * wdir)
+{
+ if( S_OK != SHGetFolderPathW( NULL,
+ CSIDL_APPDATA | CSIDL_FLAG_CREATE,
+ NULL, SHGFP_TYPE_CURRENT, wdir ) )
+ fprintf( stderr, "Can't open the vlc conf PATH\n" );
+
+ swprintf( wdir+wcslen( wdir ), L"%s", L"\\vlc\\crashdump" );
+}
+
+static void check_crashdump()
+{
+ wchar_t * wdir = (wchar_t *)malloc(sizeof(wchar_t)*MAX_PATH);
+ get_crashdump_path(wdir);
+
+ FILE * fd = _wfopen ( wdir, L"r, ccs=UTF-8" );
+ if( fd )
+ {
+ fclose( fd );
+ int answer = MessageBox( NULL, L"VLC media player just crashed." \
+ " Do you want to send a bug report to the developers team?",
+ L"VLC crash reporting", MB_YESNO);
+
+ if(answer == IDYES)
+ {
+ HINTERNET Hint = InternetOpen(L"VLC Crash Reporter", INTERNET_OPEN_TYPE_PRECONFIG, NULL,NULL,0);
+ if(Hint)
+ {
+ HINTERNET ftp = InternetConnect(Hint, L"crash.videolan.org", INTERNET_DEFAULT_FTP_PORT,
+ NULL, NULL, INTERNET_SERVICE_FTP, 0, 0);
+ if(ftp)
+ {
+ SYSTEMTIME now;
+ GetSystemTime(&now);
+ wchar_t remote_file[MAX_PATH];
+ swprintf( remote_file, L"/crashs/%04d%02d%02d%02d%02d%02d",now.wYear,
+ now.wMonth, now.wDay, now.wHour, now.wMinute, now.wSecond );
+
+ FtpPutFile( ftp, wdir, remote_file, FTP_TRANSFER_TYPE_BINARY, 0);
+ InternetCloseHandle(ftp);
+ }
+ else
+ fprintf(stderr,"Can't connect to FTP server%d\n",GetLastError());
+ InternetCloseHandle(Hint);
+ }
+ }
+
+ _wremove(wdir);
+ }
+ free((void *)wdir);
+}
+