| 
	
		|  Autor | Tema: Por que me da error? ( declarar api y realizar llamada )  (Leído 3,352 veces) |  
	| 
			| 
					
						| 70N1 
								 
								
								 Desconectado 
								Mensajes: 355
								
								
								
								
								
								   | 
 
Por que me tira estos errores? error C2371: 'SHELLEXECUTEINFO' : nueva definición; tipos básicos distintos error C2371: 'LPSHELLEXECUTEINFO' : nueva definición; tipos básicos distintos error C2373: 'ShellExecuteExA' : nueva definición; modificadores de tipo distintos error C3861: 'ShellExecuteExA': no se encontró el identificador    Este es el codigo #include "stdafx.h"
 #include <windows.h>
 
 
 typedef struct _SHELLEXECUTEINFO {
 DWORD     cbSize;
 ULONG     fMask;
 HWND      hwnd;
 LPCTSTR   lpVerb;
 LPCTSTR   lpFile;
 LPCTSTR   lpParameters;
 LPCTSTR   lpDirectory;
 int       nShow;
 HINSTANCE hInstApp;
 LPVOID    lpIDList;
 LPCTSTR   lpClass;
 HKEY      hkeyClass;
 DWORD     dwHotKey;
 union {
 HANDLE hIcon;
 HANDLE hMonitor;
 } DUMMYUNIONNAME;
 HANDLE    hProcess;
 } SHELLEXECUTEINFO, *LPSHELLEXECUTEINFO;
 
 
 BOOL ShellExecuteEx(
 _Inout_  SHELLEXECUTEINFO *pExecInfo
 );
 
 int _tmain(int argc, _TCHAR* argv[])
 
 {
 
 SHELLEXECUTEINFO ShExecInfo;
 
 ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
 ShExecInfo.fMask = NULL;
 ShExecInfo.hwnd = NULL;
 ShExecInfo.lpVerb = NULL;
 ShExecInfo.lpFile = "cmd.exe";
 ShExecInfo.lpParameters = NULL;
 ShExecInfo.lpDirectory = NULL;
 ShExecInfo.nShow = SW_MAXIMIZE;
 ShExecInfo.hInstApp = NULL;
 
 ShellExecuteEx(&ShExecInfo);
 
 
 
 return 0;
 }
 
 
 
 
 |  
						| 
								|  |  
								|  |  En línea | 
 
 70N1 |  |  |  | 
			| 
					
						| Eternal Idol 
								Kernel coder ajeno al tiempo 
								Moderador
								      Desconectado 
								Mensajes: 5.970
								
								 
								Israel nunca torturó niños, ni lo volverá a hacer.
								
								
								
								
								
								     | 
 
Eso que da error ya esta definido en windows.h ... 
 
 |  
						| 
								|  |  
								|  |  En línea | 
 
 La economía nunca ha sido libre: o la controla el Estado en beneficio del Pueblo o lo hacen los grandes consorcios en perjuicio de éste.Juan Domingo Perón
 |  |  |  | 
			| 
					
						| 70N1 
								 
								
								 Desconectado 
								Mensajes: 355
								
								
								
								
								
								   | 
 
Mira...Tengo este code en el .h y este en el cpp#include <windows.h>
 typedef struct _SHELLEXECUTEINFO {
 DWORD     cbSize;
 ULONG     fMask;
 HWND      hwnd;
 LPCTSTR   lpVerb;
 LPCTSTR   lpFile;
 LPCTSTR   lpParameters;
 LPCTSTR   lpDirectory;
 int       nShow;
 HINSTANCE hInstApp;
 LPVOID    lpIDList;
 LPCTSTR   lpClass;
 HKEY      hkeyClass;
 DWORD     dwHotKey;
 union {
 HANDLE hIcon;
 HANDLE hMonitor;
 } DUMMYUNIONNAME;
 HANDLE    hProcess;
 } SHELLEXECUTEINFO, *LPSHELLEXECUTEINFO;
 
 
 typedef  BOOL (WINAPI *ShellExecuteEx)(
 _Inout_  _SHELLEXECUTEINFO &pExecInfo
 );
 
Error   1   error C2373: 'ShExecInfo' : nueva definición; modificadores de tipo distintos
 #include "stdafx.h"
 #include "windef.h"
 
 
 
 
 
 int _tmain(int argc, _TCHAR* argv[])
 
 {
 
 
 _SHELLEXECUTEINFO ShExecInfo = { 0 };
 ShExecInfo.cbSize = sizeof(_SHELLEXECUTEINFO);
 ShExecInfo.fMask = (0x00000040);
 ShExecInfo.hwnd = NULL;
 ShExecInfo.lpVerb = NULL;
 ShExecInfo.lpFile = L"c:\\toni.exe";
 ShExecInfo.lpParameters = L"";
 ShExecInfo.lpDirectory = NULL;
 ShExecInfo.nShow = SW_SHOW;
 
 ShellExecuteEx( ShExecInfo); /////////////////////////////////////////////AQUI ME TIRA ERROR
 
 //WaitForSingleObject(ShExecInfo.hProcess, INFINITE);
 
 
 
 return 0;
 }
 
 
 
 Como puedo solucionarlo?. No doy pies con bola.
 |  
						| 
								|  |  
								|  |  En línea | 
 
 70N1 |  |  |  | 
			| 
					
						| Eternal Idol 
								Kernel coder ajeno al tiempo 
								Moderador
								      Desconectado 
								Mensajes: 5.970
								
								 
								Israel nunca torturó niños, ni lo volverá a hacer.
								
								
								
								
								
								     | 
 
Solo necesitas incluir windows.h, no hace falta REDEFINIR SHELLEXECUTEINFO y ShellExecuteEx (y menos para cambiar la definicion, el parametro de ShellExecuteEx es un puntero, no una referencia). La estructura es SHELLEXECUTEINFO, sin guion bajo al principio. Tenes que pasar la direccion de memoria de la estructura: ShellExecuteEx(&ShExecInfo);
 |  
						| 
								|  |  
								|  |  En línea | 
 
 La economía nunca ha sido libre: o la controla el Estado en beneficio del Pueblo o lo hacen los grandes consorcios en perjuicio de éste.Juan Domingo Perón
 |  |  |  | 
			| 
					
						| 70N1 
								 
								
								 Desconectado 
								Mensajes: 355
								
								
								
								
								
								   | 
 
La cosa es que estoy preparando el codigo para injectarlo y necesito hacer las llamadas a la api. Estoy lellendo y lellendo y nada. no doy pies con bola. // stdafx.h : include file for standard system include files,// or project specific include files that are used frequently, but
 // are changed infrequently
 //
 
 #pragma once
 
 // Modify the following defines if you have to target a platform prior to the ones specified below.
 // Refer to MSDN for the latest info on corresponding values for different platforms.
 #ifndef WINVER				// Allow use of features specific to Windows XP or later.
 #define WINVER 0x0501		// Change this to the appropriate value to target other versions of Windows.
 #endif
 
 #ifndef _WIN32_WINNT		// Allow use of features specific to Windows XP or later.
 #define _WIN32_WINNT 0x0501	// Change this to the appropriate value to target other versions of Windows.
 #endif
 
 #ifndef _WIN32_WINDOWS		// Allow use of features specific to Windows 98 or later.
 #define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
 #endif
 
 #ifndef _WIN32_IE			// Allow use of features specific to IE 6.0 or later.
 #define _WIN32_IE 0x0600	// Change this to the appropriate value to target other versions of IE.
 #endif
 
 #define WIN32_LEAN_AND_MEAN		// Exclude rarely-used stuff from Windows headers
 // Windows Header Files:
 #include <windows.h>
 
 // C RunTime Header Files
 #include <stdlib.h>
 #include <malloc.h>
 #include <memory.h>
 #include <tchar.h>
 
 // Disable some useless warnings
 #pragma warning(disable: 4996) // declared deprecated
 #pragma warning(disable: 4311) // pointer truncation
 #pragma warning(disable: 4312) // conversion problems
 #pragma warning(disable: 4748) // optimization disabled
 
 #pragma unmanaged
 #pragma runtime_checks( "", off )
 
 // TODO: reference additional headers your program requires here
 
 
 
 
 #include <cstdio>
 
 #include "windef.h"
 
 
 
 
 
 typedef struct SHELLEXECUTEINFO {
 DWORD     cbSize;
 ULONG     fMask;
 HWND      hwnd;
 LPCTSTR   lpVerb;
 LPCTSTR   lpFile;
 LPCTSTR   lpParameters;
 LPCTSTR   lpDirectory;
 int       nShow;
 HINSTANCE hInstApp;
 LPVOID    lpIDList;
 LPCTSTR   lpClass;
 HKEY      hkeyClass;
 DWORD     dwHotKey;
 union {
 HANDLE hIcon;
 HANDLE hMonitor;
 } DUMMYUNIONNAME;
 HANDLE    hProcess;
 } SHELLEXECUTEINFO, *LPSHELLEXECUTEINFO;
 
 
 BOOL ShellExecuteEx(
 _Inout_  SHELLEXECUTEINFO *pExecInfo
 );
 
 
 int _tmain(int argc, _TCHAR* argv[])
 
 {
 // split the program name into two chunks by :
 ULONG SEE_MASK_CLASSNAME = (0x00000001);
 char* p = strtok((char*)argv[0], ":");
 char drive[3] = { "d:" };
 sprintf(drive, "%s:", p); // Create and clear out the shellexecuteinfo
 SHELLEXECUTEINFO ShExecInfo;
 memset(&ShExecInfo, 0, sizeof(SHELLEXECUTEINFO)); // Set all the parameters
 ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
 ShExecInfo.fMask = SEE_MASK_CLASSNAME;
 ShExecInfo.lpClass = _T("AudioCD");
 ShExecInfo.lpVerb = _T("play");
 ShExecInfo.hwnd = NULL;
 ShExecInfo.lpFile = NULL;
 ShExecInfo.lpParameters = NULL;
 ShExecInfo.lpDirectory = (LPCWSTR)drive; // drive letter
 ShExecInfo.nShow = SW_SHOW; // show the app on screen
 ShExecInfo.hInstApp = NULL;
 
 BOOL result = ShellExecuteEx(&ShExecInfo);
 if (!result)
 {
 DWORD error = GetLastError();
 return error;
 }
 
 return 0;
 }
 
 
 
 
 
 |  
						| 
								|  |  
								|  |  En línea | 
 
 70N1 |  |  |  |  |  
 
	
 
 
				
					
						| Mensajes similares |  
						|  | Asunto | Iniciado por | Respuestas | Vistas | Último mensaje |  
						|   |   | Error al declarar variables. Ayuda Programación Visual Basic
 | BenRu | 2 | 2,027 |  28 Enero 2006, 20:54 pm por BenRu
 |  
						|   |   | error al declarar una matriz como publica en v.b Programación Visual Basic
 | e_nygma | 1 | 6,917 |  28 Octubre 2007, 22:01 pm por HaDeS, -
 |  
						|   |   | realizar mas de 1 llamada cuando son restringuidas Redes
 | RedZer | 0 | 2,045 |  29 Enero 2012, 19:13 pm por RedZer
 |  
						|   |   | Error en llamada a metodo Java
 | m@o_614 | 4 | 3,463 |  14 Mayo 2012, 01:03 am por [Case]
 |  
						|   |   | Error llamada recursiva Puntero C Programación C/C++
 | aisak77 | 2 | 2,107 |  30 Enero 2017, 13:44 pm por Kenji-chan
 |    |