Subversion Repositories filter_foundry

Rev

Rev 356 | Rev 444 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 356 Rev 416
Line 307... Line 307...
307
        *pcb = size;
307
        *pcb = size;
308
 
308
 
309
        return x.pv;
309
        return x.pv;
310
}
310
}
311
 
311
 
-
 
312
// Format of argument "PCWSTR changes" is "<name>\0<value>\0<name>\0<value>\0....."
-
 
313
// You can CHANGE values for any given name
-
 
314
// You can DELETE entries by setting the value to "\b" (0x08 backspace character)
-
 
315
// You cannot (yet) ADD entries.
312
BOOL UpdateVersionRaw(PVOID pvVersion, ULONG cbVersion, PVOID* pvNewVersion, ULONG* cbNewVersion, PCWSTR changes) {
316
BOOL UpdateVersionRaw(PVOID pvVersion, ULONG cbVersion, PVOID* pvNewVersion, ULONG* cbNewVersion, PCWSTR changes) {
313
        BOOL fOk = FALSE;
317
        BOOL fOk = FALSE;
314
        BOOL changesMade = FALSE;
318
        BOOL changesMade = FALSE;
315
        RsrcNode* node;
319
        RsrcNode* node;
316
 
320
 
Line 404... Line 408...
404
        }
408
        }
405
 
409
 
406
        return TRUE;
410
        return TRUE;
407
}
411
}
408
 
412
 
409
// Format of argument "PCWSTR changes" is "<name>\0<value>\0<name>\0<value>\0....."
-
 
410
// You can CHANGE values for any given name
-
 
411
// You can DELETE entries by setting the value to "\b" (0x08 backspace character)
-
 
412
// You cannot (yet) ADD entries.
-
 
413
ULONG UpdateVersionInfo(PCTSTR FileName, PCWSTR changes) {
-
 
414
        HMODULE hmod;
-
 
415
        ULONG dwError;
-
 
416
        EnumVerData ctx;
-
 
417
 
-
 
418
        dwError = NOERROR;
-
 
419
 
-
 
420
        ctx.changes = changes;
-
 
421
 
-
 
422
        if (ctx.hUpdate = _BeginUpdateResource(FileName, FALSE))
-
 
423
        {
-
 
424
                ctx.fDiscard = TRUE;
-
 
425
 
-
 
426
                // LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE requires at least Windows Vista, so we use
-
 
427
                // LOAD_LIBRARY_AS_DATAFILE
-
 
428
                if (hmod = LoadLibraryEx(FileName, 0, LOAD_LIBRARY_AS_DATAFILE/*_EXCLUSIVE*/))
-
 
429
                {
-
 
430
                        if (!EnumResourceLanguages(hmod, RT_VERSION,
-
 
431
                                MAKEINTRESOURCE(VS_VERSION_INFO),
-
 
432
                                (ENUMRESLANGPROC)(void*)EnumResLangProc, (LONG_PTR)&ctx))
-
 
433
                        {
-
 
434
                                dwError = GetLastError();
-
 
435
                        }
-
 
436
 
-
 
437
                        FreeLibrary(hmod);
-
 
438
                }
-
 
439
                else
-
 
440
                {
-
 
441
                        dwError = GetLastError();
-
 
442
                }
-
 
443
 
-
 
444
                if (!dwError && !_EndUpdateResource(ctx.hUpdate, ctx.fDiscard))
-
 
445
                {
-
 
446
                        dwError = GetLastError();
-
 
447
                }
-
 
448
        }
-
 
449
        else
-
 
450
        {
-
 
451
                dwError = GetLastError();
-
 
452
        }
-
 
453
 
-
 
454
        return dwError;
-
 
455
}
-
 
456
 
-
 
457
ULONG UpdateVersionInfoWithHandle(PCTSTR FileName, HANDLE hUpdate, PCWSTR changes) {
-
 
458
        HMODULE hmod;
-
 
459
        ULONG dwError;
-
 
460
        EnumVerData ctx;
-
 
461
 
-
 
462
        dwError = NOERROR;
-
 
463
 
-
 
464
        ctx.changes = changes;
-
 
465
        ctx.hUpdate = hUpdate;
-
 
466
 
-
 
467
        ctx.fDiscard = TRUE;
-
 
468
 
-
 
469
        // LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE requires at least Windows Vista, so we use
-
 
470
        // LOAD_LIBRARY_AS_DATAFILE
-
 
471
        if (hmod = LoadLibraryEx(FileName, 0, LOAD_LIBRARY_AS_DATAFILE/*_EXCLUSIVE*/))
-
 
472
        {
-
 
473
                if (!EnumResourceLanguages(hmod, RT_VERSION,
-
 
474
                        MAKEINTRESOURCE(VS_VERSION_INFO),
-
 
475
                        (ENUMRESLANGPROC)(void*)EnumResLangProc, (LONG_PTR)&ctx))
-
 
476
                {
-
 
477
                        dwError = GetLastError();
-
 
478
                }
-
 
479
 
-
 
480
                FreeLibrary(hmod);
-
 
481
        }
-
 
482
        else
-
 
483
        {
-
 
484
                dwError = GetLastError();
-
 
485
        }
-
 
486
 
-
 
487
        return dwError;
-
 
488
}
-
 
489
 
-
 
490
/*
413
/*
491
Usage example:
414
Usage example:
492
 
415
 
493
int main(int argc, char** argv) {
416
int main(int argc, char** argv) {
494
        // Set CompanyName to "Contoso Ltd."
417
        // Set CompanyName to "Contoso Ltd."