Ver Mensaje Individual
  #10  
Antiguo 26-02-2011
rogeliogamberro rogeliogamberro is offline
Miembro
 
Registrado: oct 2008
Posts: 23
Reputación: 0
rogeliogamberro Va por buen camino
Unhappy

Intente agregar a un nuevo proyecto el codigo de c publicado

Código:
#include <Registry.hpp>
#include <shlobj.h>

void
RegisterFileType(AnsiString Ext, AnsiString PathExec)
{
  // Ext tipo de archivo : EXTENSION
  // PathExec: RUTA COMPLETA del ejecutable que queremos que lo abra

  TRegistry *Registry = new TRegistry;
  try{
    Registry->RootKey = HKEY_CLASSES_ROOT;
    // Crear la clave .Ext
    Registry->OpenKey("." + Ext, true);
    try{
      // Ccrear el valor con el nombre del tipo de archivo para esta clave (extfile)
      Registry->WriteString("", Ext + "file");
    }
    __finally{
      Registry->CloseKey();
    }
    // Crear una clave nueva para el nombre del tipo de archivo dado anteriormente (extfile)
    Registry->CreateKey(Ext + "file");
    // Crear una nueva clave para el icono por defecto
    Registry->OpenKey(Ext + "file\\DefaultIcon", true);
    // Crear un valor con el icono (PathExec.exe,0)
    try{
      Registry->WriteString("", PathExec + ",0");
    }
    __finally{
      Registry->CloseKey();
    }
    Registry->OpenKey(Ext + "file\\shell\\open\\command", true);
    //Crear el valor para el ejecutable que abre el tipo de archivo (PathExec.exe "%1")
    try{
      Registry->WriteString("", PathExec + " \"%1\"");
    }
    __finally{
      Registry->CloseKey();
    }
  }
  __finally{
    delete Registry;
  }
  // Notificar al sistema el cambio efectuado
  SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, 0, 0);
}
Agregue la declaracion de la rutina en el .h y ohhh sorpresa... Me da 4 errores...

Código:
[C++ Error] shlobj.h(1762): E2238 Multiple declaration for 'FVSHOWINFO'
[C++ Error] shlobj.h(1936): E2238 Multiple declaration for 'FOLDERSETTINGS'
[C++ Error] shlobj.h(3717): E2238 Multiple declaration for 'DESKBANDINFO'
[C++ Error] shlobj.h(4808): E2238 Multiple declaration for 'SHELLFLAGSTATE'
los cuales hacen referencia a las siguientes estructuras en el archivo shlobj.h

Código:
shlobj.h

// --------------------------------------------------------------------

typedef struct
{
    // Stuff passed into viewer (in)
    DWORD cbSize;           // Size of structure for future expansion...
    HWND hwndOwner;         // who is the owner window.
    int iShow;              // The show command

    // Passed in and updated  (in/Out)
    DWORD dwFlags;          // flags
    RECT rect;              // Where to create the window may have defaults
    IUnknown *punkRel;      // Relese this interface when window is visible

    // Stuff that might be returned from viewer (out)
    OLECHAR strNewFile[MAX_PATH];   // New File to view.

} FVSHOWINFO, *LPFVSHOWINFO;

// --------------------------------------------------------------------
typedef struct
    {
    UINT ViewMode;       // View mode (FOLDERVIEWMODE values)
    UINT fFlags;         // View options (FOLDERFLAGS bits)
    } FOLDERSETTINGS, *LPFOLDERSETTINGS;

// --------------------------------------------------------------------

typedef struct {
    DWORD       dwMask;
    POINTL      ptMinSize;
    POINTL      ptMaxSize;
    POINTL      ptIntegral;
    POINTL      ptActual;
    WCHAR       wszTitle[256];
    DWORD       dwModeFlags;
    COLORREF    crBkgnd;
} DESKBANDINFO;

// --------------------------------------------------------------------
typedef struct {
    BOOL fShowAllObjects : 1;
    BOOL fShowExtensions : 1;
    BOOL fNoConfirmRecycle : 1;
    BOOL fShowSysFiles : 1;
    BOOL fShowCompColor : 1;
    BOOL fDoubleClickInWebView : 1;
    BOOL fDesktopHTML : 1;
    BOOL fWin95Classic : 1;
    BOOL fDontPrettyPath : 1;
    BOOL fShowAttribCol : 1;
    BOOL fMapNetDrvBtn : 1;
    BOOL fShowInfoTip : 1;
    BOOL fHideIcons : 1;
    UINT fRestFlags : 3;
} SHELLFLAGSTATE, * LPSHELLFLAGSTATE;
Por favor... Alguien me podria ayudar a solucionarlo?? Muchas gracias!!

PD: utilizo Borland C++ Builder 5
Responder Con Cita