Hello again,
I tried something...
Here I´ll show the hole code after <snap, because the script doesn´t read the XML-File
#include <windows.h>
#include <windowsx.h>
#include "main.h"
#include <stdio.h>
#include <stdlib.h>
#include <tchar.h>
#include <winioctl.h>
#include <string.h>
static HANDLE ghInstance;
wchar_t variable[200];
FILE* src;
HKEY hkey;
DWORD dwValue;
DWORD dwType;
DWORD dwCount = sizeof ( DWORD );
#define MulDiv(a,b,c) (((a)*(b))/(c))
HBITMAP hbit;
HFONT BuildFont(LPCTSTR pszFontFace, int nFontSize, BOOL fBold)
{
HDC hDC;
int nHeight;
LOGFONT lgf;
hDC = GetDC(NULL);
nHeight = -MulDiv(nFontSize, GetDeviceCaps(hDC, LOGPIXELSY), 72);
ReleaseDC(NULL, hDC);
memset(&lgf, 0, sizeof(lgf));
lgf.lfHeight = nHeight;
lgf.lfWeight = fBold ? FW_BOLD: FW_NORMAL;
lgf.lfCharSet = DEFAULT_CHARSET;
lgf.lfOutPrecision = OUT_DEFAULT_PRECIS;
lgf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
lgf.lfQuality = DEFAULT_QUALITY;
lgf.lfPitchAndFamily = DEFAULT_PITCH;
wcscpy(lgf.lfFaceName, pszFontFace);
return CreateFontIndirect(&lgf);
}
int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpszCmdLine, int nCmdShow)
{
// delete old hardware.txt
DeleteFile(L"\\Temp\\hardware.txt");
// create W'indow#######################################
WNDCLASS wc;
ghInstance = hInstance;
// Get system dialog information.
if (!GetClassInfo(NULL, L"Dialog", &wc))
return 0;
// Register our own dialog.
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDR_ICO_MAIN));
wc.lpszClassName = L"PCinstall";
if (!RegisterClass(&wc))
return 0;
hbit = LoadBitmap(hInstance, MAKEINTRESOURCE(IDR_BMP_LOGO));
HWND hWnd;
hWnd = CreateWindow(L"PCinstall", // Window Class Name
L"Dialog", // The title bar text
WS_VISIBLE | SS_BITMAP, // Only need to make the window
// visible in CE
0, // Don't bother with size
0, // as palm apps fill the
CW_USEDEFAULT, // whole screen
CW_USEDEFAULT,
NULL, // No parent (Top Level)
NULL, // No Menu
hInstance,
NULL);
ShowWindow (hWnd, nCmdShow);
UpdateWindow (hWnd);
HWND imgCtrl = CreateWindow( _T("STATIC"), NULL, SS_CENTERIMAGE | SS_BITMAP | WS_CHILD | WS_VISIBLE, 0, 0 , 480, 90, hWnd, NULL, NULL, NULL);
SendMessage(imgCtrl,STM_SETIMAGE, (WPARAM)IMAGE_BITMAP,(LPARAM)hbit);
HFONT hFont = BuildFont(TEXT("Tahoma"), 20, TRUE);
HWND hwnd2 = CreateWindow( _T("STATIC"), _T("HARDWAREERKENNUNG LÄUFT"), WS_CHILD | WS_VISIBLE | SS_CENTER, 10, 130 , 460, 60, hWnd, NULL, NULL, NULL);
SendMessage (hwnd2, WM_SETFONT, (WPARAM)hFont, TRUE);
HWND hwnd3 = CreateWindow( _T("STATIC"), _T("PNA NICHT AUSSCHALTEN!."), WS_CHILD | WS_VISIBLE | SS_CENTER, 10, 200 , 460, 60, hWnd, NULL, NULL, NULL);
SendMessage (hwnd3, WM_SETFONT, (WPARAM)hFont, TRUE);
UpdateWindow (hWnd);
_sleep(2);
//Sirf //Atlas ###############################################################
HANDLE hFile = CreateFile(L"\\Windows\\WisGPS200.exe\0", GENERIC_READ , FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile != INVALID_HANDLE_VALUE)
{
wcscpy(variable, L"Atlas|");
}
else
{
wcscpy(variable, L"Sirf|");
}
CloseHandle(hFile);
<snip
.
.
.
.
<snap
//get software-version###############################
HANDLE hFile6 = CreateFile(TEXT("\\My Flash Disk\\navigation\\licenses\feature.xml\0"), GENERIC_READ , FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile6 == INVALID_HANDLE_VALUE)
{
wcscat(variable, L"NO");
}
else
{
// open file in buffer
char *readFile(const char *filename);
//code heavily changed from http://www.cplusplus.com/reference/clibrary/cstdio/fread/
FILE *file = fopen("\\My Flash Disk\\navigation\\licenses\feature.xml", "rb");
if (!file) return 0;
//get file size
fseek(file, 0, SEEK_END);
size_t filesize = ftell(file); //files >4GB?
rewind(file);
//get memory to contain the whole file
char *buffer = (char*)malloc(filesize+1);
if (!buffer) return 0;
//read file
size_t temp;
if ((temp=fread(buffer, 1, filesize+1, file))!=filesize){
free(buffer);
fclose(file);
return 0;
}
//look for entries in buffer
int main();
wchar_t hStr6[100];
wchar_t hStr7[100];
if (!buffer) exit(-1); //konnte feature.xml nicht lesen!
char *position = strstr(buffer, "appVersion=\"");
int appVersionLength;
char *temp1 = position+sizeof("appVersion=\"");
for (appVersionLength=0; *temp1!='"'; temp++) appVersionLength++;
char *appVersion = (char *)malloc(appVersionLength+1);
strncpy(appVersion, position+sizeof "appVersion=\"", appVersionLength);
swprintf(hStr7, L"%d", appVersion);
wcscat(variable, hStr7);
int editionNameLength;
char *temp2 = position+sizeof("editionName=\"");
for (editionNameLength=0; *temp2!='"'; temp++) editionNameLength++;
char *editionName = (char *)malloc(editionNameLength+1);
strncpy(editionName, position+sizeof "editionName=\"", editionNameLength);
swprintf(hStr6, L"%d", editionName);
wcscat(variable, hStr6);
free(appVersion);
free(editionName);
}
CloseHandle(hFile6);
//Write vars to file####################################
src = _wfopen(L"\\Temp\\hardware.txt", L"a+");
fputws(variable, src);
fclose(src);
Sleep(3000);
return 0;
}
Please,,, could someone help me???
Greets
Pitter