Menú

Mostrar Mensajes

Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.

Mostrar Mensajes Menú

Mensajes - 43H4FH44H45H4CH49H56H45H

#222
Cuando necesite guardar imagenes en una BD los ejemplos que encontre primero guardaban la imagen en disco. Por eso yo lo hice de este modo:

Código (csharp) [Seleccionar]

System.IO.Stream derecho = new System.IO.MemoryStream();
this.picDerecha.Image.Save(derecho, System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] imgDerecha = new byte[derecho.Length];
derecho.Position = 0;
derecho.Read(imgDerecha, 0, System.Convert.ToInt32(derecho.Length));
derecho.Close();


Código (csharp) [Seleccionar]
myRow["IDerecha"] = imgDerecha;

Cita de: Hartigan en 13 Junio 2010, 20:46 PM
gracias voy a probar, pero así leyendo por encima he visto esto:


img.Save(fs, System.Drawing.Imaging.ImageFormat.Png);


Si la imágen que yo he escogido anteriormente para mi picturebox no es png que hago??.

Solo cambias:

Código (csharp) [Seleccionar]
System.Drawing.Imaging.ImageFormat.Jpeg

por la extension que necesites.
#223
Fijate aqui como se puede hacer como archivo adjunto:

http://geeks.ms/blogs/sergiotarrillo/archive/2006/11/16/cadenas-de-conexion-desde-net-para-sql-server-2005.aspx

asi solo registras tu BD en el servidor y la conexion es la misma.

O si prefieres hacerlo como hasta ahora, puedes usar este ejemplo:

http://www.elguille.info/NET/adonet/Crear_una_base_de_datos_de_SQL_Server_mediante_codigo_de_Visual_Basic.htm

Lo modificas y en tiempo de ejecucion puedes obtener la cadena de conexion para tu BD.
#224
Basicamente se hace una captura de la pantalla mediante codigo y se obtiene los pixeles (getpixel) de determinadas coordenadas, luego estas se comparan con una o varias imagenes base (almacenadas en una base de datos) que sirven para obtener por ejemplo el nombre del usuario o la posicion de algun jugador. Al principio es mejor hacerlo con pictures box para ver como funciona, luego se pueden omitir e incluso la captura de la pantalla.

Es el metodo basico, porque se puede hacer solamente con vectores de numeros (omitiendo las imagenes base).
#225
Cita de: erick185 en  9 Junio 2010, 02:37 AM
Buen dia

Recien acabo de terminar un programa sencillo en vb.net.
- y quiero crearle un instalador a mi programa, pero no se como hacerlo y creo que habran algunos errores con respecto al codigo de mi programa, me explico:

- El programa lo hice en Visual Basic.net 2005.
- La base de datos esta en SQL Server 2005.

En mi programa (vb.net) use un modulo el cual contiene la conexion para poder usar la base de datos (sql server): (use public para poder usar la conexion en todo mi programa)


Código:
Imports System.Data
Imports System.Data.SqlClient

Module Module1
    Public conectar As New SqlConnection("Data Source=Pc01\sqlexpress;Initial Catalog=Proyecto;Integrated Security=True")

End Module

Por logica esta conexion si funciona en mi compu y el programa me anda bien, pero si quiero usar mi proyecto en otra compu me dara error de conexion pues la conexion no es la misma y tendria que modificarla


- Bueno, lo que deseo hacer es que el programa pueda instalarse en cualquier computadora, y que funcione perfectamente, pero no tengo ni idea de como hacer el instalador, y que pasaria con el codigo del modulo para conectarme con la base de datos?

- ah se me olvidaba, tengo que pasar mi programa a un exe, antes de crearle el instalador?


Cualquier duda pueden preguntar, de antemano gracias


salu2


Puedes usar una cadena de conexion con una BD adjuntada, asi en el instalador puedes añadir el archivo *.mdf y simplemente adjuntar dicho archivo al servidor SQLServer y no tener que crearla en dicho servidor, o podrias comprobar si existe y crearla en el mismo.

Respecto al instalador si solo estas practicando y lo haces mediante un proyecto de instalación en VS y mas adelante quieres utilizar el mismo método para alguna aplicación comercial dependiendo de su alcance ten en cuenta el tema de la licencia.

El uso de SQL Server depende de las caracteristicas de tu programa y el tipo de uso que tendrá, porque puedes optar por Acces y evitar la instalación de MSSQL si no es necesaria.

Hay mas cosas que considerar, pero creo que esto es suficiente.
#226
Cita de: Foxzer en  9 Junio 2010, 01:58 AM
Hola, hace poco senti una curiosidad sobre este tema, me gustaria saber el funcionamiento de un bot en un juego, es decir como desde mi aplicacion mandar ordenes que el juego entienda y las ejecute, me gustaria saber por donde empezar a buscar informacion sobre este tema, como interpretar las ordenes del juego para adaptarlas a mi programa y como conectarlos entre si, si alguien me pudiera orientar estaria agredcido!

Creo que esto puede orientarte un poco:

http://nidodecuervos.comentalo.net/bot-simple-php-world-of-warcraft-linux.htm

Bueno, no conozco el juego que mencionas, pero no veo complicado el enviarle ordenes si esta hecho en ASx (Flash) y supongo que tiene trucos o combinaciones de teclas para atajos u otros que se pueden aprovechar, pero depende del nivel de proteccion que tenga dicho juego para algun bot, respecto a que el bot pueda reconocer areas o personajes del juego, simplemente con una captura de la pantalla o indicando las coordenadas y un procesado de imagenes (metodo cutre pero sirve para empezar) que en c#.net te lo da practicamente hecho solo implementar un algoritmo adecuado de comparacion de imagenes + una pequeña BD para garantizar el reconocimiento de dichas areas o personajes.
Se me ocurre que se podria averiguar como envia y recibe la informacion del servidor para implementar la IA de modo que funcione de forma mas precisa.
Bueno de seguro hay mejores modos de hacerlo, pero tu eres el que debe ir investigando al respecto.
#227
Cita de: eldiegofg en  7 Junio 2010, 16:46 PM
Saludos a toda esta maravillosa comunidad. Estoy necesitando integrar la imagen de una webcam en un form, dentro de un picturebox. Estuve buscando mucho por la red y ninguno de los ejemplos que encontre funciono. Estoy trabajando con VS 2010, ojala puedan darme una manito.
Saludos, y muchas gracias por su ayuda y por su tiempo

Lo mas sencillo es utilizar las API's de Windows, hay ejemplos de clases ya hechas en la red, hasta en el mismo foro:

http://foro.elhacker.net/vbnet/clase_para_capturar_fotos_con_la_webcam_c-t172433.0.html

para utilizar esa clase  debes tener en tu form un picture box y un combo box.

Pero es mucho mejor utilizar DirectShow.NET

http://www.codeproject.com/KB/directx/directshownet.aspx?display=Print

En ese enlace esta mas detallado.
#228
Desarrollo Web / Re: Acceder a la camara web
6 Junio 2010, 19:09 PM
Ya mencionaste a Flash y de hecho AS --> ya tienes la respuesta a la 1era busqueda en google... :huh:

http://www.google.com.bo/#hl=es&&sa=X&ei=J9MLTNK4HoO88gbVuZWNBw&ved=0CBMQBSgA&q=capturar+webcam+as3&spell=1&fp=504413e5e9bfcdb8

por lo menos respecto a flash, en el 1er enlace de la busqueda te muestra el source y el ejemplo
#229
Programación General / Re: Consulta J#
5 Junio 2010, 05:46 AM
Cita de: Hacktor en  5 Junio 2010, 01:14 AM
Hola, queria saber si es posible controlar el volumen de windows con J#.net

Si se puede, este ejemplo en c#.net disminuye el volumen general de windows puedes pasarlo a J#.NET y modificarlo a tu gusto, hay muchos mas en la red.

Código (csharp) [Seleccionar]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Media;
using System.Runtime.InteropServices;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public const int MMSYSERR_NOERROR = 0;
        public const int MAXPNAMELEN = 32;
        public const int MIXER_LONG_NAME_CHARS = 64;
        public const int MIXER_SHORT_NAME_CHARS = 16;
        public const int MIXER_GETLINEINFOF_COMPONENTTYPE = 0x3;
        public const int MIXER_GETCONTROLDETAILSF_VALUE = 0x0;
        public const int MIXER_GETLINECONTROLSF_ONEBYTYPE = 0x2;
        public const int MIXER_SETCONTROLDETAILSF_VALUE = 0x0;
        public const int MIXERLINE_COMPONENTTYPE_DST_FIRST = 0x0;
        public const int MIXERLINE_COMPONENTTYPE_SRC_FIRST = 0x1000;
        public const int MIXERLINE_COMPONENTTYPE_DST_SPEAKERS =
        (MIXERLINE_COMPONENTTYPE_DST_FIRST + 4);
        public const int MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE =
        (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 3);
        public const int MIXERLINE_COMPONENTTYPE_SRC_LINE =
        (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 2);
        public const int MIXERCONTROL_CT_CLASS_FADER = 0x50000000;
        public const int MIXERCONTROL_CT_UNITS_UNSIGNED = 0x30000;
        public const int MIXERCONTROL_CONTROLTYPE_FADER =
        (MIXERCONTROL_CT_CLASS_FADER | MIXERCONTROL_CT_UNITS_UNSIGNED);
        public const int MIXERCONTROL_CONTROLTYPE_VOLUME =
        (MIXERCONTROL_CONTROLTYPE_FADER + 1);

        [DllImport("winmm.dll", CharSet = CharSet.Ansi)]
        private static extern int mixerClose(int hmx);
        [DllImport("winmm.dll", CharSet = CharSet.Ansi)]
        private static extern int mixerGetControlDetailsA(int hmxobj, ref
MIXERCONTROLDETAILS pmxcd, int fdwDetails);
        [DllImport("winmm.dll", CharSet = CharSet.Ansi)]
        private static extern int mixerGetDevCapsA(int uMxId, MIXERCAPS
        pmxcaps, int cbmxcaps);
        [DllImport("winmm.dll", CharSet = CharSet.Ansi)]
        private static extern int mixerGetID(int hmxobj, int pumxID, int
        fdwId);
        [DllImport("winmm.dll", CharSet = CharSet.Ansi)]
        private static extern int mixerGetLineControlsA(int hmxobj, ref
MIXERLINECONTROLS pmxlc, int fdwControls);
        [DllImport("winmm.dll", CharSet = CharSet.Ansi)]
        private static extern int mixerGetLineInfoA(int hmxobj, ref
MIXERLINE pmxl, int fdwInfo);
        [DllImport("winmm.dll", CharSet = CharSet.Ansi)]
        private static extern int mixerGetNumDevs();
        [DllImport("winmm.dll", CharSet = CharSet.Ansi)]
        private static extern int mixerMessage(int hmx, int uMsg, int
        dwParam1, int dwParam2);
        [DllImport("winmm.dll", CharSet = CharSet.Ansi)]
        private static extern int mixerOpen(out int phmx, int uMxId,
        int dwCallback, int dwInstance, int fdwOpen);
        [DllImport("winmm.dll", CharSet = CharSet.Ansi)]
        private static extern int mixerSetControlDetails(int hmxobj, ref
MIXERCONTROLDETAILS pmxcd, int fdwDetails);

        public struct MIXERCAPS
        {
            public int wMid;
            public int wPid;
            public int vDriverVersion;
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = MAXPNAMELEN)]
            public string szPname;
            public int fdwSupport;
            public int cDestinations;
        }

        public struct MIXERCONTROL
        {
            public int cbStruct;
            public int dwControlID;
            public int dwControlType;
            public int fdwControl;
            public int cMultipleItems;
            [MarshalAs(UnmanagedType.ByValTStr,
            SizeConst = MIXER_SHORT_NAME_CHARS)]
            public string szShortName;
            [MarshalAs(UnmanagedType.ByValTStr,
            SizeConst = MIXER_LONG_NAME_CHARS)]
            public string szName;
            public int lMinimum;
            public int lMaximum;
            [MarshalAs(UnmanagedType.U4, SizeConst = 10)]
            public int reserved;
        }

        public struct MIXERCONTROLDETAILS
        {
            public int cbStruct;
            public int dwControlID;
            public int cChannels;
            public int item;
            public int cbDetails;
            public IntPtr paDetails;
        }

        public struct MIXERCONTROLDETAILS_UNSIGNED
        {
            public int dwValue;
        }

        public struct MIXERLINE
        {
            public int cbStruct;
            public int dwDestination;
            public int dwSource;
            public int dwLineID;
            public int fdwLine;
            public int dwUser;
            public int dwComponentType;
            public int cChannels;
            public int cConnections;
            public int cControls;
            [MarshalAs(UnmanagedType.ByValTStr,
            SizeConst = MIXER_SHORT_NAME_CHARS)]
            public string szShortName;
            [MarshalAs(UnmanagedType.ByValTStr,
            SizeConst = MIXER_LONG_NAME_CHARS)]
            public string szName;
            public int dwType;
            public int dwDeviceID;
            public int wMid;
            public int wPid;
            public int vDriverVersion;
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = MAXPNAMELEN)]
            public string szPname;
        }

        public struct MIXERLINECONTROLS
        {
            public int cbStruct;
            public int dwLineID;

            public int dwControl;
            public int cControls;
            public int cbmxctrl;
            public IntPtr pamxctrl;
        }

        private bool GetVolumeControl(int hmixer, int componentType,
        int ctrlType, out MIXERCONTROL mxc, out int vCurrentVol)
            {
            // This function attempts to obtain a mixer control.
            // Returns True if successful.
            MIXERLINECONTROLS mxlc = new MIXERLINECONTROLS();
            MIXERLINE mxl = new MIXERLINE();
            MIXERCONTROLDETAILS pmxcd = new MIXERCONTROLDETAILS();
            MIXERCONTROLDETAILS_UNSIGNED du = new
                MIXERCONTROLDETAILS_UNSIGNED();
            mxc = new MIXERCONTROL();
            int rc;
            bool retValue;
            vCurrentVol = -1;
            mxl.cbStruct = Marshal.SizeOf(mxl);
            mxl.dwComponentType = componentType;
            rc = mixerGetLineInfoA(hmixer,ref mxl,
                MIXER_GETLINEINFOF_COMPONENTTYPE );
            if(MMSYSERR_NOERROR == rc)
                {
                int sizeofMIXERCONTROL = 152;
                int ctrl = Marshal.SizeOf(typeof(MIXERCONTROL));
                mxlc.pamxctrl = Marshal.AllocCoTaskMem(sizeofMIXERCONTROL);
                mxlc.cbStruct = Marshal.SizeOf(mxlc);
                mxlc.dwLineID = mxl.dwLineID;
                mxlc.dwControl = ctrlType;
                mxlc.cControls = 1;
                mxlc.cbmxctrl = sizeofMIXERCONTROL;
                // Allocate a buffer for the control
                mxc.cbStruct = sizeofMIXERCONTROL;
                // Get the control
                rc = mixerGetLineControlsA(hmixer,ref mxlc,
                    MIXER_GETLINECONTROLSF_ONEBYTYPE);
                if(MMSYSERR_NOERROR == rc)
                    {
                    retValue = true;
                    // Copy the control into the destination structure
                    mxc = (MIXERCONTROL)Marshal.PtrToStructure(
                        mxlc.pamxctrl,typeof(MIXERCONTROL));
                    }
                    else
                    {
                    retValue = false;
                    }
                int sizeofMIXERCONTROLDETAILS =
                    Marshal.SizeOf(typeof(MIXERCONTROLDETAILS));
                int sizeofMIXERCONTROLDETAILS_UNSIGNED =
                    Marshal.SizeOf(typeof(MIXERCONTROLDETAILS_UNSIGNED ));
                pmxcd.cbStruct = sizeofMIXERCONTROLDETAILS;
                pmxcd.dwControlID = mxc.dwControlID;
                pmxcd.paDetails = Marshal.AllocCoTaskMem(sizeofMIXERCONTROLDETAILS_UNSIGNED) ;
                pmxcd.cChannels = 1;
                pmxcd.item = 0;
                pmxcd.cbDetails = sizeofMIXERCONTROLDETAILS_UNSIGNED;
                rc = mixerGetControlDetailsA(hmixer,ref pmxcd,
                    MIXER_GETCONTROLDETAILSF_VALUE);
                du = (MIXERCONTROLDETAILS_UNSIGNED)Marshal.PtrToStructure(
                    pmxcd.paDetails, typeof(MIXERCONTROLDETAILS_UNSIGNED));
                vCurrentVol = du.dwValue;
                return retValue;
                }
            retValue = false;
            return retValue;
            }
        private static bool SetVolumeControl(int hmixer, MIXERCONTROL mxc, int volume)
            {
            // This function sets the value for a volume control.
            // Returns True if successful
            bool retValue;
            int rc;
            MIXERCONTROLDETAILS mxcd = new MIXERCONTROLDETAILS();
            MIXERCONTROLDETAILS_UNSIGNED vol = new
            MIXERCONTROLDETAILS_UNSIGNED();
            mxcd.item = 0;
            mxcd.dwControlID = mxc.dwControlID;
            mxcd.cbStruct = Marshal.SizeOf(mxcd);
            mxcd.cbDetails = Marshal.SizeOf(vol);

            // Allocate a buffer for the control value buffer
            mxcd.cChannels = 1;
            vol.dwValue = volume;

            // Copy the data into the control value buffer
            mxcd.paDetails = Marshal.AllocCoTaskMem(Marshal.SizeOf(
            typeof(MIXERCONTROLDETAILS_UNSIGNED)));
            Marshal.StructureToPtr(vol, mxcd.paDetails, false);

            // Set the control value
            rc = mixerSetControlDetails(hmixer, ref mxcd,
            MIXER_SETCONTROLDETAILSF_VALUE);

            if (MMSYSERR_NOERROR == rc)
            {
                retValue = true;
            }
            else
            {
                retValue = false;
            } return retValue;
        }

        public int GetVolume()
        {
            int mixer;
            MIXERCONTROL volCtrl = new MIXERCONTROL();
            int currentVol;
            mixerOpen(out mixer, 0, 0, 0, 0);
            int type = MIXERCONTROL_CONTROLTYPE_VOLUME;
            GetVolumeControl(mixer,
            MIXERLINE_COMPONENTTYPE_DST_SPEAKERS, type, out volCtrl, out currentVol);
            mixerClose(mixer);
            return currentVol;
        }

        public void SetVolume(int vVolume)
        {
            int mixer;
            MIXERCONTROL volCtrl = new MIXERCONTROL();
            int currentVol;
            mixerOpen(out mixer, 0, 0, 0, 0);
            int type = MIXERCONTROL_CONTROLTYPE_VOLUME;
            GetVolumeControl(mixer,
            MIXERLINE_COMPONENTTYPE_DST_SPEAKERS, type, out volCtrl, out currentVol);
            if (vVolume > volCtrl.lMaximum) vVolume = volCtrl.lMaximum;
            if (vVolume < volCtrl.lMinimum) vVolume = volCtrl.lMinimum;
            SetVolumeControl(mixer, volCtrl, vVolume);
            GetVolumeControl(mixer,
            MIXERLINE_COMPONENTTYPE_DST_SPEAKERS, type, out volCtrl, out currentVol);
            if (vVolume != currentVol)
            {
                throw new Exception("Cannot Set Volume");
            }
            mixerClose(mixer);

        }
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
           
        }

        private void button1_Click(object sender, EventArgs e)
        {
            MessageBox.Show( this.GetVolume().ToString());
            //set the master volume
             this.SetVolume(1000);
            //Display the new volume
            MessageBox.Show(this.GetVolume().ToString());
        }
    }
}
#230
Prueba con este enlace:

http://geeks.ms/blogs/lfranco/archive/2008/07/01/how-to-c-243-mo-insertar-un-winform-dentro-de-un-control-tabpanel.aspx

en otro caso puedes usar el Control de Usuario que es una buena opcion.