* self-extracting .exe to be saved as.  So lets create it. */
* self-extracting .exe to be saved as.  So lets create it only if it does not exist. */
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow){  int               i;  int               iArgC;  char              szBuf[MAX_BUF];  char              szArgVBuf[MAX_BUF];  char              szFileFullPath[MAX_BUF];  char              szSeaExe[MAX_BUF];  char              szNsZipName[MAX_BUF];  char              szAppName[MAX_BUF];#ifdef SSU_DEBUG  char              szOutputStr[MAX_BUF];#endif  WIN32_FIND_DATA   findFileData;  HANDLE            hFindFile;  BOOL              bSelfUpdate;  if(*lpszCmdLine == '\0')  {    if(GetModuleFileName(NULL, szAppName, sizeof(szAppName)) == 0L)    {      PrintError("GetModuleFileName() failed", ERROR_CODE_SHOW);      exit(1);    }    ParsePath(szAppName, szBuf, sizeof(szBuf), PP_FILENAME_ONLY);    ShowUsage(szBuf);    exit(1);  }  iArgC = GetArgC(lpszCmdLine);  bSelfUpdate = FALSE;#ifdef SSU_DEBUG  wsprintf(szOutputStr, "ArgC: %d\n", iArgC);  for(i = 0; i < iArgC; i++)  {    GetArgV(lpszCmdLine, i, szArgVBuf, sizeof(szArgVBuf));    itoa(i, szBuf, 10);    lstrcat(szOutputStr, "    ");    lstrcat(szOutputStr, szBuf);    lstrcat(szOutputStr, ": ");    lstrcat(szOutputStr, szArgVBuf);    lstrcat(szOutputStr, "\n");  }  MessageBox(NULL, szOutputStr, "Output", MB_OK);#endif  /* Get the first parameter */  GetArgV(lpszCmdLine, 0, szSeaExe, sizeof(szSeaExe));  if(lstrcmpi(szSeaExe, "-g") == 0)  {    /* The first parameter is "-g".     * Create a new nszip that contains nsinstall.exe in itself */    GetArgV(lpszCmdLine, 1, szNsZipName, sizeof(szNsZipName));    GetArgV(lpszCmdLine, 2, szSeaExe, sizeof(szSeaExe));    if(!FileExists(szSeaExe))    {      wsprintf(szBuf, "file not found: %s", szSeaExe);      PrintError(szBuf, ERROR_CODE_HIDE);      exit(1);    }    if(GetModuleFileName(NULL, szAppName, sizeof(szAppName)) == 0L)    {      PrintError("GetModuleFileName() failed", ERROR_CODE_SHOW);      exit(1);    }    if(!FileExists(szAppName))    {      wsprintf(szBuf, "File not found: %s", szAppName);      PrintError(szBuf, ERROR_CODE_HIDE);      exit(1);    }    if(CopyFile(szAppName, szNsZipName, FALSE) == FALSE)    {      wsprintf(szBuf, "Error creating %s", szNsZipName);      PrintError(szBuf, ERROR_CODE_SHOW);      exit(1);    }    AddFile(szNsZipName, szSeaExe);    return(0);  }  else  {    /* The first parameter is not "-g".  Assume that it's the name of the     * self-extracting .exe to be saved as.  So lets create it. */    EnumResourceNames(NULL, "FILE", (ENUMRESNAMEPROC)ExtractFilesProc, (LONG)szSeaExe);    if(!FileExists(szSeaExe))    {      wsprintf(szBuf, "file not found: %s", szSeaExe);      PrintError(szBuf, ERROR_CODE_HIDE);      exit(1);    }  }  for(i = 1; i < iArgC; i++)  {    GetArgV(lpszCmdLine, i, szArgVBuf, sizeof(szArgVBuf));    GetFullPathName(szArgVBuf, sizeof(szFileFullPath), szFileFullPath, NULL);    hFindFile = FindFirstFile(szFileFullPath, &findFileData);    if(hFindFile == INVALID_HANDLE_VALUE)    {      wsprintf(szBuf, "file not found: %s", szArgVBuf);      PrintError(szBuf, ERROR_CODE_HIDE);      exit(1);    }    do    {      char szFile[MAX_BUF];      if(!(findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))      {        // We need to pass to AddFile() whatever kind of path we were passed,        // e.g. simple, relative, full        strcpy(szFile, szFileFullPath);        strcpy(strrchr(szFile, '\\') + 1, findFileData.cFileName);        AddFile(szSeaExe, szFile);      }    } while(FindNextFile(hFindFile, &findFileData));    FindClose(hFindFile);  }  return(0);}