Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
S

steve_rm

@steve_rm
About
Posts
438
Topics
314
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • cannot convert from string to System.IntPtr
    S steve_rm

    Hello, I have a P/Invoke to a C++ function:

    int dll_registerAccount(char* uri, char* reguri, char*);

    So I have done this:

    [DllImport("pjsipDlld")]
    static extern int dll_registerAccount(IntPtr uri,
    IntPtr reguri);

    When I use this in my code:

    success = dll_registerAccount("Bob", "Joe");

    I get the following error message: cannot convert from string to System.IntPtr Am I going about this the wrong way? Many thanks for any advice,

    C# c++ help question

  • Trying to show progress using DownloadDataAsync
    S steve_rm

    Hello, VS 2008 SP1 I am using the DownloadDataAysnc. But the ProgressChanged event doesn't show progress until after the data has been downloaded. Even when I try and download a data which is contained in a big file. The programs remains responsive so I know it is doing something. However, it is when the progress has completed that the progressChanged event fires. I known this as the progressChanged and the DownloadDataCompleted fire immediately after each other. However, they should be a pause as the file is quite big. This is the code snippet I am currently using. And the output below. What is strange the e.progresspercentage is 100%. And seems to get called twice. Many thanks for any advise, Results:

    Progress changed Version userstate: [ Version1 ]
    progressBar1.Value [ 100 ]
    Progress changed Version userstate: [ Version1 ]
    progressBar1.Value [ 100 ]
    Completed data: [ 1.0.11 ]

    private void UpdateAvailable()
    {
    WebClient wbCheckUpdates = new WebClient();
    wbCheckUpdates.DownloadProgressChanged += new DownloadProgressChangedEventHandler(wbCheckUpdates_DownloadProgressChanged);
    wbCheckUpdates.DownloadDataCompleted += new DownloadDataCompletedEventHandler(wbCheckUpdates_DownloadDataCompleted);
    DownloadFiles df = new DownloadFiles();
    string webServerURL = df.webServerPath;

            wbCheckUpdates.DownloadDataAsync(new Uri(Path.Combine(webServerURL, "version.txt")), "Version1"); 
        }
    

    void wbCheckUpdates_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
    {
    Console.WriteLine("Progress version changed userstate: [ " + e.UserState + " ]");
    progressBar1.Value = e.ProgressPercentage;
    Console.WriteLine("progressBar1.Value [ " + this.progressBar1.Value + " ]");
    }

    void wbCheckUpdates_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
    {
    byte[] result = e.Result;
    Console.WriteLine("Completed data: [ " + System.Text.ASCIIEncoding.Default.GetString(result) + " ]");
    }

    C# mobile visual-studio question announcement

  • Downloading unknown number of files from web server
    S steve_rm

    Hello, VS 2008 SP1 I am using the web client to download a file. Which works ok. However, now I have to download many, and the number of files to download will change everyday. And will not know the name of the files. I am not sure how I can get the web client to know which files have been downloaded or not? I was thinking of using a for loop to download each file. But I will never know how many there are to download? The web client could download the same file twice? Many thanks for any suggestions,

    private void btnStartDownload_Click(object sender, EventArgs e)
    {
    WebClient client = new WebClient();
    client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged);
    client.DownloadFileCompleted += new AsyncCompletedEventHandler(client_DownloadFileCompleted);

    // Starts the download
    client.DownloadFileAsync(new Uri("SomeURLToFile"), "SomePlaceOnLocalHardDrive");
    
    btnStartDownload.Text = "Download In Process";
    btnStartDownload.Enabled = false;
    

    }

    C# visual-studio sysadmin question

  • Creating a updater that will download and update installation files
    S steve_rm

    Hello, VS 2008 SP1 I have created a application that I have installed on the user computer. However, I want the application to be self-updating. But I am not sure if this would really update the application. The application will download all the files from the web server, and replace the files in the directory where the program as been installed to. The user will restart the application. I am just want to be sure, because I can't replace the installed files with the updated ones. As the application will be running. So really the application cannot delete/replace itself. So, I was thinking that I could download into another directory, if the program is installed in this directory 'program files/application/1.0.0' then I could download the files to 'program files/application/1.0.1'. However, when the program restarts, how can it know that it has to execute from the 1.0.1 directory? I can't use clickonce or the updater block for this. Many thanks for any advice,

    C# visual-studio sysadmin question announcement

  • Creating batch file to install/uninstall C# app
    S steve_rm

    Hello, I am using the following bat file to install my application on a user computer. However, the client want to be able uninstall the application if the application is installed, and then install the new version of the application. However, I have 2 problems. 1) how can I detect if the application is installed or not? 2) If it is installed, how can I uninstall it? The application is a C# 2005. Many thanks for any advice,

    @ECHO OFF
    :: Copy the configuration file
    copy config.xml "%AppData%\DataLinks.xml"

    :: Search for the CONFIG file, if this doesn't exit then the user doesn't have the .Net framework 2.0
    SET FileName=%windir%\Microsoft.NET\Framework\v2.0.50727\CONFIG
    IF EXIST %FileName% GOTO INSTALL_DIALER
    ECHO.You currently do not have the Microsoft(c) .NET Framework 2.0 installed.
    ECHO.This is required by the setup program for CAT Dialer
    ECHO.
    ECHO.The Microsoft(c) .NET Framework 2.0 will now be installed on you system.
    ECHO.After completion setup will continue to install CAT Dialer on your system.
    ECHO.
    :: Install the .Net framework and then run setup to install the CAT Dialerr
    PAUSE
    ECHO Installing... this could take serveral minutes...Please wait....
    START /WAIT NetFx20SP2_x86.exe
    :: If the user cancels the installation of the framework exit batch file
    IF errorlevel 1 GOTO EOF
    Start CATSoftphone.exe
    ECHO ON
    EXIT

    :: .Net framework has been skipped contine to install the dialer.
    :INSTALL_DIALER
    ECHO *** Skiped Dotnet Framework 2.0.50727 ***
    ECHO Installing... Please wait...
    START CATSoftphone.exe
    ECHO ON
    EXIT

    C# csharp question workspace dotnet xml

  • Network connections detecting
    S steve_rm

    Hello, VS 2008 SP1 I am using the code below to test whether the user is connected using either a wireless or LAN connection. i.e. that the cable is plugged in, or the wireless is switch off. The code works fine for this. However, if you can spot any potential problems with this or you know of a better way I would be interested to learn more. However, the client would like us to check if the user is connected using a modem as well. As you can see from my source code I am looking for connection that start with either "Local Area Connection" or "Wireless Network Connection". This is ok. However, the problem is that the modem name could be anything, as when the user sets up their modem connection using the 'new connection wizard' they can call this anything. So if my switch statement I don't know what to look for. Any suggestions would be most helpfull,

    // Checks if Network is either connected by LAN or Wireless
    public bool IsNetworkConnected()
    {
    NetworkInterface[] networkCards = NetworkInterface.GetAllNetworkInterfaces();
    bool connected = false;

            // Loop through to find the one we want to check for connectivity.
            // Connection can have different numbers appended so check that the 
            // network connections start with the conditions checked below.
            foreach (NetworkInterface nc in networkCards)
            {
                // Check LAN
                if (nc.Name.StartsWith("Local Area Connection"))
                {
                    if (nc.OperationalStatus == OperationalStatus.Up)
                    {
                        connected = true;
                    }
                }
    
                // Check for Wireless
                if (nc.Name.StartsWith("Wireless Network Connection"))
                {
                    if (nc.OperationalStatus == OperationalStatus.Up)
                    {
                        connected = true;
                    }
                }
            }
    
            return connected;
        }
    
    C# visual-studio sysadmin help

  • creating a linked list
    S steve_rm

    Hello, The reason I am not using the STL list, is I am practicing C programming and wanted to get up to speed on both pointers and lists. Thanks,

    C / C++ / MFC data-structures performance announcement

  • creating a linked list
    S steve_rm

    Hello, Thanks for the source. However, I had done it a similar way like that. However, I changed to having the list_t structure as I have been informed that is not good practice to have the head and tail as global and should be contained in a structure. I think this makes it more generic. That was why I was having some problems with my source code. Thanks,

    C / C++ / MFC data-structures performance announcement

  • creating a linked list
    S steve_rm

    Hello, I am creating a linked list. I have found that the best way to develop the linked list is to have the head and tail in another structure. My products struct will be nested inside this structure. And I should be passing the list to the function for adding and deleting. I find this concept confusing. I have implemented the initialize, add, and clean_up. However, I am not sure that I have done that correctly. When I add a product to the list I declare some memory using calloc. But I am thinking shouldn't I be declaring the memory for the product instead. I am really confused about this adding. Many thanks for any suggestions,

    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>

    #define PRODUCT_NAME_LEN 128

    typedef struct product_data
    {
    int product_code;
    char product_name[PRODUCT_NAME_LEN];
    int product_cost;
    struct product_data_t *next;
    }product_data_t;

    typedef struct list
    {
    product_data_t *head;
    product_data_t *tail;
    }list_t;

    void add(list_t *list, int code, char name[], int cost);
    void initialize(list_t *list);
    void clean_up(list_t *list);

    int main(void)
    {
    list_t *list = NULL;

    initialize(list);
    add(list, 10, "Dell Inspiron", 1500);
    clean\_up(list);
    
    getchar();
    
    return 0;
    

    }

    void add(list_t *list, int code, char name[], int cost)
    {
    // Allocate memory for the new product
    list = calloc(1, sizeof(list_t));
    if(!list)
    {
    fprintf(stderr, "Cannot allocated memory");
    exit(1);
    }

    if(list)
    {
        // First item to add to the list
        list->head->product\_code = code;
        list->head->product\_cost = cost;
        strncpy(list->head->product\_name, name, sizeof(list->head->product\_name));
        // Terminate the string
        list->head->product\_name\[127\] = '/0';
    } 
    

    }

    // Initialize linked list
    void initialize(list_t *list)
    {
    // Set list node to null
    list = NULL;
    list = NULL;
    }

    // Release all resources
    void clean_up(list_t *list)
    {
    list_t *temp = NULL;

    while(list)
    {
        temp = list->head;
        list->head = list->head->next;
        free(temp);    
    }
    list = NULL;
    list = NULL;
    temp = NULL;
    

    }

    C / C++ / MFC data-structures performance announcement

  • Multi-threading using AutoResetEvent [modified]
    S steve_rm

    Hello, When you say that setting a bool is a atomic operation. Does that mean the the operation will has to complete all of it, or fail? What would be the difference in setting either a string or a integer? Thanks,

    C# csharp css database help career

  • Multi-threading using AutoResetEvent [modified]
    S steve_rm

    Hello, I solved my problem. It was something in the RunWorkercompleted. However, there is one more thing. The registerSuccess and AccountInUse are global because they are been accessed from 2 different threads. Would it be better to put a lock on them? Many thanks

    C# csharp css database help career

  • Multi-threading using AutoResetEvent [modified]
    S steve_rm

    Hello, C# 2005 I am using a background worker to process some login information. However, the background worker has to stop and wait for 2 events to happen. Once these have finished the background worker can complete its job. They are callbacks that will call the Set() method of the AutoResetEvent. So I am using AutoResetEvent to set when these 2 events have finished. However, I seemed to be getting this error message "Exception has been thrown by the target of an invocation." And Inner exception Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index". The exception usually fires when the registration success leaves scope. Many thanks for any advice,

    // Waiting for 'Account in use' and 'Register success or failure'
    AutoResetEvent[] loginWaitEvents = new AutoResetEvent[]
    {
    new AutoResetEvent(false),
    new AutoResetEvent(false)
    };

    private void bgwProcessLogin_DoWork(object sender, DoWorkEventArgs e)
    {
    Console.WriteLine("Wait until event is set or timeout");
    loginWaitEvents[0].WaitOne(3000, true);

          if (this.accountInUseFlag)
          {
                    if (this.lblRegistering.InvokeRequired)
                    {
                        this.lblRegistering.Invoke(new UpdateRegisterLabelDelegate(this.UpdateRegisterLabel), "Account in use");
                    }
                    else
                    {
                        this.lblRegistering.Text = "Account in use";
                    }
                    // Failed attemp
                    e.Cancel = true;
                    // Reset flag
                    this.accountInUseFlag = false;
                    return;
           }
           else
           {
                    // Report current progress
                    this.bgwProcessLogin.ReportProgress(7, "Account accepted");
           }
    
            Console.WriteLine("Just Wait the result of successfull login or not");
            loginWaitEvents\[1\].WaitOne();
           
            if (this.registerSuccess)
            {
                    // Report current progress
                    this.bgwProcessLogin.ReportProgress(7, "Register Succesfull");  
                    // Reset flag
                    this.registerSuccess = false;
            }
            else
            {
                    if (this.lblRegistering.InvokeRequired)
                    {
                        this.lblRegisteri
    
    C# csharp css database help career

  • Checking if a UDP port is open
    S steve_rm

    Hello, VS2008 SP1 Private Function IsPortAvailable() As Boolean Using sock As New Socket(AddressFamily.InterNetwork, _ SocketType.Dgram, _ ProtocolType.Udp) sock.Connect(VaxSIPUserAgentOCX.GetMyIP(), 5060) Return sock.Connected End Using End Function Using this code I thought I had this problem solved. However, after testing I have found that the socket always connects. Even if the port is being used by another application. The port I am checking is 5060 UDP. My application when it starts will check if this is available. If another applications is using it. i.e. SJ Phone etc. The application will inform the user. However, the socket always returns true. I have checked this with netstat -aon (cmd) and I can see that the port is being used. I am checking the port on my local computer. So my IP address is 10.10.10.120. Under the netstat I can see this 0.0.0.0:5060. Why all the zeros. Could this be part of the problem Is there another method for checking this? I have looked at udp client, and wondering about winsock. Thanks,

    Visual Basic testing beta-testing help question

  • ClickOnce - The Web server does not appear to have FrontPage Server Extensions installed
    S steve_rm

    Hello, VS 2008 running on Windows XP. I am trying to publish my application using clickonce on to a remote server which is running Windows server 2003 Enterprize edition. Failed to connect to 'http://10.10.10.8/CATDialer/' with the following error: Unable to create the Web site 'http://10.10.10.8/CATDialer/'. The Web server does not appear to have FrontPage Server Extensions installed. I have installed FrontPage Server extensions without any problems. However, the problem remains. I am not sure but is this because of some security issues that have not been set correctly or a configuration on the IIS. I have browsed google, but cannot find any solution to this problem. Many thanks for any suggestions,

    C# windows-admin help visual-studio sysadmin security

  • Editing resource files for different languages, string don't persist
    S steve_rm

    Hello VS 2008 I have a resource file called Form1.fr-FR.resx which has been added to my project when I set the local and language of the form. In my Form1.fr-FR.resx I have button1.Text, button2.Text. I have set the culture to fr-FR so when the form starts its displays the french language in the buttons. However, I would like to include some string of my own in this file. I have added strName, strAddress as I want to display these in a message box. However, when I add more control to the form the string I have added get deleted. When I open the Form1.fr-FR.resx using edit plus the string are there. However, when I try and display them, I just get a blank. Is there some reason that the strings don't persist in the resource file? Some code that I am using: Dim rm As New ResourceManager("LanCulture.Form1", Me.[GetType]().Assembly) Console.WriteLine(rm.GetString("strName", Thread.CurrentThread.CurrentUICulture)) Many thanks for any advice on this,

    C# visual-studio question learning

  • clickonce register COM problem
    S steve_rm

    Hello VS 2008 The 2 users that have tried to run the application get this error. "CATWinApp has encountered a problem and needs to close" "An unhandled exception ('System.Runtime.InteropServices.COMException') occurred in CATWinApp.exe [2220]. Just-in-debugging this exception failed with the following error: No installed debugger has just-in-time dubugging enabled. In visual studio, just-in-debugging can be enabled from Tool/Options/Debugging/Just-in-time." The users don't have any visual studio. Only the 2.0, 3.0, and 3.5 framework. Which is needed to run the application. They are only users so they don't have any development tools. In my application I have a ActiveX control (COM), called "VaxSIPUserAgentOCX.ocx" I have registered this on my developer box using this: "regsvr32 VaxSIPUserAgentOCX.ocx". The application run ok on my computer but no one elses. In my references when I select them in the properties name in my application I have the following: AxInterop.VAXSIPUSERAGENTOCX and Interop.VAXSIPUSERAGENTOCXLib. In the properties I have local copy set to true. I think the problem could be that is not registered on the users' computer. However, I am not sure how to register them. I have tried "regsvr32 VAXSIPUSERAGENTOCXLib" But comes up with "Entry point cannot be found". Then I go to publish I click on Application Files and select Include (Auto) Requried for both AxInterop.VAXSIPUSERAGENTOCX and Interop.VAXSIPUSERAGENTOCXLib. Could this ActiveX be causing the problem? And if what is the best method to solve this problem? Many thanks for any advice, Steve

    C# com visual-studio help question csharp

  • Finding an menuItem in the MenuContext
    S steve_rm

    Hello, VS 2008 I am adding menuItems to a menuContext. However, I only want to allow a maximum of 10 menuItems to be added. This works ok. However, if a menuItem is about to be added. Which is already contained in the menuContext. Then I want to get the index of this, so that I can remove it. And add in index 0. The idea is to add phone numbers, and display the most recent one that was dialed. This is why I am adding at index 0. However, if a phone number is already in the menuContext then I need to find it so that I can remove it. I have tried using the contains, Find, and IndexOf methods, but no use. See comments below. I have tried using the Dictionary and IList to keep track of the items. However, this doesn't seem be the right solution either. Many thanks for any suggestions, //Dictionary<int,> RedialedItems = new Dictionary<int,>(); //IList dialedNumbers; //Add a new number to the redial history public void AddToRedialHistory(string number) { this.shortcutRedialMenu = new MenuItem(); this.shortcutRedialMenu.Text = number; //Trying to get an index of the value I am looking for. //int index = this.ctxRedialMenu.MenuItems.IndexOf(shortcutRedialMenu); //index = this.ctxRedialMenu.MenuItems.IndexOfKey("1"); //index = Convert.ToInt16(this.ctxRedialMenu.MenuItems.Contains(shortcutRedialMenu)); //Only keep redial history for a maximum of 10 numbers. //if greater then 10, remove the last one index 10. int count = this.ctxRedialMenu.MenuItems.Count; if (count > 9) { this.ctxRedialMenu.MenuItems.RemoveAt(9); } //Add to the zero index so that all the number are displayed //in reverse order. Most recent displayed at the top. this.ctxRedialMenu.MenuItems.Add(0, shortcutRedialMenu); //Adding them to the dictionary. //this.RedialedItems.Add(this.shortcutRedialMenu.Index, shortcutRedialMenu.Text); //Add event handler for clicking on the shortcut menu. this.shortcutRedialMenu.Click += new EventHandler(this.ShortCutRedial_Clicked); }

    C# database visual-studio

  • http GET Request
    S steve_rm

    Problem solved. I missed of the http://

    C# help question sysadmin sales workspace

  • http GET Request
    S steve_rm

    Hello, I am using http to get a request from a server. The server has been setup to receive a customer ID and return the balance. However, I am getting an error message with the code I am using below: "Invalid URI: The URI scheme is not valid." From what I can make out by using wireshark is that the server expects a customerID and the balance will be returned. I am not sure that the data is another parameter that the server expects. So how can I write the URL that expects a parameter like the customer ID? Many thanks for any extra help, private void btnGetBalance_Click(object sender, EventArgs e) { try { HttpWebRequest wr = (HttpWebRequest)WebRequest.Create("000.000.00.00:8080/billing/servlet/comm.billing.GetBalance?Date=17:54:24&CustomerID=8057"); HttpWebResponse res = (HttpWebResponse)wr.GetResponse(); StreamReader sr = new StreamReader(res.GetResponseStream()); string balance = sr.ReadToEnd(); } catch(UriFormatException ex) { MessageBox.Show(ex.Message); } catch(Exception ex) { MessageBox.Show(ex.Message); } }

    C# help question sysadmin sales workspace

  • typed dataset schema relating to xml file
    S steve_rm

    Hello, VS 2008 I have typed dataset and have added a single data table named dsMissedCalls.xsd and dtMissedCalls. I would like to save some missed calls for my application. The table is very small not more than 10 rows. Example. dtMissedCalls(ID, Caller, DateAndTime) I have created a XML file, and I would like the xml file to have the schema of the typed dataset (dsMissedCalls.xsd). Before when I have been creating xml file. I would add a new xml file. Then click the "Create Schema" button. That would creaet the schema for the xml file. However, as I have created a typed dataset that already has a schema. The question is. How do I get my xml file to relate to that schema? So basically I have created a typed dataSet and would like to save added rows to the xml file. The code below works, but I want to xml to use the dataset schema. Many thanks for help with this confusing question, DataRow row; row = ds.Tables[0].NewRow(); row["Caller"] = callersName; row["DateTime"] = DateTime.Now.ToShortDateString(); ds.Tables[0].Rows.Add(row); ds.WriteXml(missedCallsXML, XmlWriteMode.DiffGram);

    C# question xml database visual-studio help
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups