Rev 308 | Rev 315 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 308 | Rev 314 | ||
---|---|---|---|
Line 516... | Line 516... | ||
516 | DWORD dwAttrib = GetFileAttributes(szPath); |
516 | DWORD dwAttrib = GetFileAttributes(szPath); |
517 | return (dwAttrib != INVALID_FILE_ATTRIBUTES && |
517 | return (dwAttrib != INVALID_FILE_ATTRIBUTES && |
518 | !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY)); |
518 | !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY)); |
519 | } |
519 | } |
520 | 520 | ||
521 | Boolean extractFile(LPCTSTR lpType, LPCTSTR lpName, const char* outName) { |
521 | Boolean extract_file(LPCTSTR lpType, LPCTSTR lpName, const char* outName) { |
522 | HGLOBAL datah; |
522 | HGLOBAL datah; |
523 | LPVOID datap; |
523 | LPVOID datap; |
524 | HRSRC datarsrc; |
524 | HRSRC datarsrc; |
525 | size_t datalen; |
525 | size_t datalen; |
526 | 526 | ||
Line 544... | Line 544... | ||
544 | OSErr do_make_standalone(char* dstname, int bits) { |
544 | OSErr do_make_standalone(char* dstname, int bits) { |
545 | Boolean res; |
545 | Boolean res; |
546 | char err[MAX_PATH + 200]; |
546 | char err[MAX_PATH + 200]; |
547 | 547 | ||
548 | //DeleteFile(dstname); |
548 | //DeleteFile(dstname); |
549 | if (extractFile("TPLT", MAKEINTRESOURCE(1000 + bits), dstname)) { |
549 | if (extract_file("TPLT", MAKEINTRESOURCE(1000 + bits), dstname)) { |
550 | HMODULE hSrcmod; |
550 | HMODULE hSrcmod; |
551 | hSrcmod = LoadLibraryEx(dstname, NULL, LOAD_LIBRARY_AS_DATAFILE); |
551 | hSrcmod = LoadLibraryEx(dstname, NULL, LOAD_LIBRARY_AS_DATAFILE); |
552 | if (hSrcmod) { |
552 | if (hSrcmod) { |
553 | res = doresources(hSrcmod, dstname, bits); |
553 | res = doresources(hSrcmod, dstname, bits); |
554 | FreeLibrary(hSrcmod); // do it now, otherwise DeleteFile() will not work |
554 | FreeLibrary(hSrcmod); // do it now, otherwise DeleteFile() will not work |
Line 576... | Line 576... | ||
576 | } |
576 | } |
577 | 577 | ||
578 | return res ? noErr : ioErr; |
578 | return res ? noErr : ioErr; |
579 | } |
579 | } |
580 | 580 | ||
581 | OSErr make_standalone(StandardFileReply *sfr){ |
581 | Boolean check_unicows() { |
582 | OSErr tmpErr, outErr; |
582 | // Unicows.dll is required for Win9x to implement the BeginUpdateResource functionalities |
- | 583 | ||
583 | char dstname[MAX_PATH+1]; |
584 | char dstname[MAX_PATH+1]; |
584 | 585 | ||
585 | if (!isWin32NT()) { |
586 | if (isWin32NT()) { |
- | 587 | // Modern Windows don't require UnicoWS |
|
- | 588 | return true; |
|
- | 589 | } else { |
|
586 | HMODULE hLib; |
590 | HMODULE hLib; |
587 | 591 | ||
588 | hLib = LoadLibraryA("UNICOWS.DLL"); |
592 | hLib = LoadLibraryA("UNICOWS.DLL"); |
589 | if (!hLib) { |
593 | if (!hLib) { |
590 | char* sysdir; |
594 | char* dstname; |
591 | 595 | ||
- | 596 | // Try to install UnicoWS automatically |
|
- | 597 | dstname = (char*)malloc(MAX_PATH); |
|
- | 598 | GetSystemDirectoryA(dstname, MAX_PATH); |
|
- | 599 | strcat(dstname, "\\UNICOWS.DLL"); |
|
592 | // Unicows.dll is required to implement the BeginUpdateResource functionalities in Win9x |
600 | extract_file("DLL", "UNICOWS", dstname); // included in make_win.rc |
593 | 601 | ||
594 | sysdir = (char*)malloc(MAX_PATH); |
602 | hLib = LoadLibraryA("UNICOWS.DLL"); |
- | 603 | if (!hLib) { |
|
595 | GetSystemDirectoryA(sysdir, MAX_PATH); |
604 | // This should not happen |
596 | alertuser(_strdup("To build standalone plugins using this version of\nWindows, you need to install UNICOWS.DLL\n\nPlease download it from the Internet\nand place it into following directory:"), sysdir); |
605 | alertuser(_strdup("To build standalone plugins using this version of\nWindows, you need to install UNICOWS.DLL\n\nPlease download it from the Internet\nand place it into your system directory")); |
597 | free(sysdir); |
606 | free(dstname); |
598 | 607 | ||
599 | return false; |
608 | return false; |
600 | } |
609 | } |
601 | else { |
610 | else { |
602 | FreeLibrary(hLib); |
611 | FreeLibrary(hLib); |
- | 612 | return true; |
|
- | 613 | } |
|
- | 614 | } |
|
- | 615 | else { |
|
- | 616 | FreeLibrary(hLib); |
|
- | 617 | return true; |
|
- | 618 | } |
|
603 | } |
619 | } |
604 | } |
620 | } |
605 | 621 | ||
- | 622 | OSErr make_standalone(StandardFileReply *sfr){ |
|
- | 623 | OSErr tmpErr, outErr; |
|
- | 624 | char dstname[MAX_PATH+1]; |
|
- | 625 | ||
606 | outErr = noErr; |
626 | outErr = noErr; |
607 | 627 | ||
- | 628 | check_unicows(); |
|
- | 629 | ||
608 | // Make 32 bit: |
630 | // Make 32 bit: |
609 | // Destfile = no64_or_32(chosenname) |
631 | // Destfile = no64_or_32(chosenname) |
610 | myp2cstrcpy(dstname, sfr->sfFile.name); |
632 | myp2cstrcpy(dstname, sfr->sfFile.name); |
611 | remove_64_filename_prefix(dstname); |
633 | remove_64_filename_prefix(dstname); |
612 | tmpErr = do_make_standalone(&dstname[0], 32); |
634 | tmpErr = do_make_standalone(&dstname[0], 32); |