Ejemplo n.º 1
0
void DListTest()
{
    DLinkList La;
    DataType deletelem;
    int i;

    if( InitDLinkList(La,3))
    {
        InsertDLinkList( La,1,7);
        InsertDLinkList( La,1,8);
        InsertDLinkList( La,5,9);

    }

    PrintDLinkList( La);
    DeleteLinkList( La, 3, &deletelem);
    printf("the delete valaue is :%d\nthe new list is :\n",deletelem);
    PrintDLinkList( La);

    printf("\nuse get element from lis ,the value is: ");
    for(i=1; i<6; i++)
    {
        GetElem_DL( La, i, &deletelem);
        printf("\n%d",deletelem);
    }
}
Ejemplo n.º 2
0
DWORD WINAPI DoUninstall(LPVOID lpParam)
{
  InstData *idata;
  HANDLE fin;
  HWND delstat;
  bstr *str;
  char *startmenu, *desktop, *installdir;

  installdir = GetInstallDir(product);

  if (!SetCurrentDirectory(installdir)) {
    str = bstr_new();
    bstr_assign(str, "Could not access install directory ");
    bstr_append(str, installdir);
    DisplayError(str->text, TRUE, TRUE);
    /* Pointless to try to free the bstr, since DisplayError ends the
     * process */
  }

  fin = CreateFile("install.log", GENERIC_READ, 0, NULL,
                   OPEN_EXISTING, 0, NULL);

  if (fin) {
    idata = ReadOldInstData(fin, product, installdir);
    CloseHandle(fin);
    DeleteFile("install.log");

    RemoveService(idata->service);

    delstat = GetDlgItem(mainDlg, ST_DELSTAT);
    DeleteFileList(idata->instfiles, delstat, NULL);
    DeleteFileList(idata->extrafiles, delstat, NULL);

    startmenu = GetStartMenuDir(idata->flags & IF_ALLUSERS, idata);
    desktop = GetDesktopDir();
    DeleteLinkList(startmenu, idata->startmenu, delstat);
    DeleteLinkList(desktop, idata->desktop, delstat);

    RemoveUninstall(startmenu, product, TRUE);

    SetCurrentDirectory(desktop);       /* Just make sure we're not in the 
                                         * install directory any more */

    str = bstr_new();
    if (!RemoveWholeDirectory(installdir)) {
      bstr_assign(str, "Could not remove install directory:\n");
      bstr_append(str, installdir);
      bstr_append(str, "\nYou may wish to manually remove it later.");
      DisplayError(str->text, FALSE, FALSE);
    }

    if (!RemoveWholeDirectory(startmenu)) {
      bstr_assign(str, "Could not remove Start Menu directory:\n");
      bstr_append(str, startmenu);
      bstr_append(str, "\nYou may wish to manually remove it later.");
      DisplayError(str->text, FALSE, FALSE);
    }

    bstr_assign(str, UninstallKey);
    bstr_appendpath(str, product);
    RegDeleteKey(HKEY_LOCAL_MACHINE, str->text);
    bstr_free(str, TRUE);

    bfree(startmenu);
    bfree(desktop);
    FreeInstData(idata, TRUE);
  } else {
    bfree(product);
    bfree(installdir);          /* Normally FreeInstData frees these */
    str = bstr_new();
    bstr_assign(str, "Could not read install.log from ");
    bstr_append(str, installdir);
    DisplayError(str->text, TRUE, TRUE);
    /* Pointless to try to free the bstr, since DisplayError ends the
     * process */
  }
  ShowWindow(GetDlgItem(mainDlg, ST_DELDONE), SW_SHOW);
  EnableWindow(GetDlgItem(mainDlg, BT_DELOK), TRUE);
  SetFocus(GetDlgItem(mainDlg, BT_DELOK));
  return 0;
}