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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
C

Crazy Joe Devola

@Crazy Joe Devola
About
Posts
41
Topics
16
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Saving usercontrol design-time properties
    C Crazy Joe Devola

    thank you. It is working now.

    C# question design algorithms tutorial

  • Saving usercontrol design-time properties
    C Crazy Joe Devola

    I swear I have been searching for an answer for hours but could not find any understandable example or article :-( How do I make a property of a Winform usercontrol retain it's design time value? I added a new UserControl object. I put a label on the control. Added a property called "KeyText". I saw in few articles the attribute "DesignerSerailizationVisibility" mentioned so I added it as well.

    [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
    public string KeyText
    {
    get { return label1.Text; }
    set
    {
    label1.Text = value;
    }
    }

    In the control, the default value of label1.Text is "X". Then I added the control to a form. The property "KeyText" showed as one of the properties of the control. Great. So I changed it to "A". The design-time form showed A". Great. I compiled and ran the program - the control on the form showed "X" instead of "A". What do I need to change to make the property persisteable? In VB6 I use something called PropBag to save and read design time properties.

    C# question design algorithms tutorial

  • Winhttp and p12 certificate
    C Crazy Joe Devola

    The server company sent me a .PEM certificate to install. Once I did that, the problem was solved. Thank you.

    Visual Basic help sysadmin security cryptography

  • Winhttp and p12 certificate
    C Crazy Joe Devola

    The fact i am using VB6 right now should not matter. The program is using Windows winhttp.dll, a COM object. I could have used C++ and still have the same problem.

    Visual Basic help sysadmin security cryptography

  • Winhttp and p12 certificate
    C Crazy Joe Devola

    Thank you. I think the "-s" option cannot be used with "-i". I tried to add it, but the utility just printed it's syntax text, as if the parameters were incorrect. Like so: winhttpcertcfg -i CertificateFile.p12-c LOCAL_MACHINE\My -s CertifiaceFile -a COMPUTERNAME\USERNAME -p PASSWORD on the other hand, it was accepted with "-l": winhttpcertcfg -l -c LOCAL_MACHINE\MY -s CertificateFile

    Visual Basic help sysadmin security cryptography

  • Winhttp and p12 certificate
    C Crazy Joe Devola

    I am writing a client program in VB6 which will interface to a server over HTTP. The company who runs the server provided me with a certificate file called SomeCertificate.p12. My program is running on Windows XP. This is the operating system the customer is using. I am trying to find how to use this certificate when sending requests to the server. Here is what I have done so far: 1. Copied the certificate file to my test computer. 2. Using Internet Explorer V8, I did "Tools|Internet Options|Content|Certificates|Trusted Root Authorities" and imported the certificate. 3. Installed the winhttpcertcfg tool. 4. Ran the following from command prompt: "winhttpcertcfg -i SomeCertificate.p12 -c LOCAL_MACHINE\My -a COMPUTERNAME\USERNAME -p PasswordFromServerCompany" the output was something like this. I replaced the different tokens with dummy strings: Imported certificate: CN=string1 OU=string2 O=string3 L=string4 C=string5 Private key access has already been granted for account: COMPUTERNAME\USERNAME 5. My VB6 code looks something like this: Private WithEvents m_ServerObj As WinHttpRequest Set m_ServerObj = New WinHttpRequest m_ServerObj.Open "GET", "https://serveraddress" Call m_ServerObj.SetClientCertificate("LOCAL_MACHINE\Personal\SomeCertificate") m_ServerObj.Send TextToSend The Send call causes an exception: "A certificate is required to complete client authentication" I tried different strings in the SetClientCertificate call but I keep getting the same error. I'd appreciate any help and tips. What am i doing wrong? Is my code wrong? Did I use winhttpcertcfg incorrectly? thank you.

    Visual Basic help sysadmin security cryptography

  • Named pipes: C# server, C++ client
    C Crazy Joe Devola

    I think the problem was found.... On stackoverflow, someone posted this answer: C#'s NamedPipeClientStream, NamedPipeServerStream automatically append "\.\\pipe\" to the name I changed the C# code to open the pipe just as "mypipe" and now the connection is successful.

    C# csharp c++ sysadmin question

  • Named pipes: C# server, C++ client
    C Crazy Joe Devola

    I thought of that. I tried changing the server side to InOut - it did not help. i also tried changing the client to GENERIC_WRITE without GENERIC_READ - it didn't work either. Thank you for all the advise, tips and time you spent trying to help - much appreciated.

    C# csharp c++ sysadmin question

  • Named pipes: C# server, C++ client
    C Crazy Joe Devola

    Server: C# NamedPipeServerStream pipeServer = new NamedPipeServerStream("\\\\.\\pipe\\mypipe", PipeDirection.In, 1, PipeTransmissionMode.Byte, PipeOptions.Asynchronous); // Wait for a connection pipeServer.BeginWaitForConnection(new AsyncCallback(WaitForConnectionCallBack), pipeServer); Client: C++

    	hPipe=CreateFile("\\\\\\\\\\\\\\\\.\\\\\\\\pipe\\\\\\\\mypipe", 
    	                 GENERIC\_READ | GENERIC\_WRITE,
    	                 0,
    	                 NULL,
    	                 OPEN\_EXISTING,
    	                 0,
    	                 NULL) ;
    	if ( hPipe!=INVALID\_HANDLE\_VALUE) 
    	{
    		return 0; //Success!!!
    	}
    
    	err = GetLastError();
    	if(err!=ERROR\_PIPE\_BUSY)
    	{
    		printf("Could not open pipe, GetLastError=%u\\n", err);
    		return -1 ;
    	}
    
    	printf("Could not open pipe, GetLastError=%u. WaitNamedPipe.\\n", err);
    	if(! WaitNamedPipe(pipe\_name,2000))
    	{
    		printf("Could not open pipe\\n");
    		return -1 ;
    	}
    

    again: C++ client with C++ server - works. C# client with C# server - works. C++ client with C# server - does not works. Thank you.

    C# csharp c++ sysadmin question

  • Named pipes: C# server, C++ client
    C Crazy Joe Devola

    Yes i do :-) for some reason the codeproject shows just 1 backslash. I do have it like this:

    "\\\\.\\pipe\\mypipe"

    C# csharp c++ sysadmin question

  • Named pipes: C# server, C++ client
    C Crazy Joe Devola

    This is how the client opens the pipe:

    hPipe=CreateFile("\\\\.\\pipe\\mypipe",
    GENERIC_WRITE,//GENERIC_READ | GENERIC_WRITE,
    0,
    NULL,
    OPEN_EXISTING,
    0,
    NULL) ;

    if ( hPipe!=INVALID_HANDLE_VALUE)
    {
    return 0; //Success!!!
    }

    err = GetLastError();
    if(err!=ERROR_PIPE_BUSY)
    {
    printf("Could not open pipe, GetLastError=%u\n", err);
    return -1 ;
    }

    Create file returns an invalid handle. GetLastError() returns 2.

    C# csharp c++ sysadmin question

  • Named pipes: C# server, C++ client
    C Crazy Joe Devola

    thank you. I have Process Explorer but I don't know how to see list of objects for a process. I used the search option to search for "mypipe". It shows that the server has a handle to \Device\NamedPipe\pipe\mypipe . I tried to check the client to open "\\Device\\NamedPipe\\pipe\\mypipe" but that didn't help (I didn't expect it to work anyway).

    C# csharp c++ sysadmin question

  • Named pipes: C# server, C++ client
    C Crazy Joe Devola

    it returns error code 2 - ERROR_FILE_NOT_FOUND

    C# csharp c++ sysadmin question

  • Named pipes: C# server, C++ client
    C Crazy Joe Devola

    I wrote 2 pairs of named pipe client/server programs: 1st pair in C# (.NET 4) 2nd pair in C++ (un-managed) All 4 test programs use the same pipe name \\\\.\pipe\mypipe The C# pair work fine with each other - I send a message from the client and it is received by the server. The C++ pair work also fine with each other. But... when I try to run the C# client with the C++ server, or the C++ client with the C# server - then it doesn't work. The client is unable to connect to the server. Is there something preventing the C++ client from working with the .NET server? Should it work? Thank you.

    C# csharp c++ sysadmin question

  • Catch not working, why?
    C Crazy Joe Devola

    It was just a test code. I was more interested in understanding why the try/catch did not work. The imageView was less of a concern in this excercise. Once I was able to trap the error , it turned out to be "not enough memory" because the bitmap I was using was too big.

    Android debugging java question

  • Catch not working, why?
    C Crazy Joe Devola

    Solved by adding a catch for Throwable try { ImageView imageV = (ImageView) findViewById(R.id.imageView); Log.i(TAG, "before setImageResource"); imageV.setImageResource(R.drawable.merle); } catch (Exception ex) { Log.e(TAG,ex.getMessage().toString()); } catch (Throwable ex) { Log.e(TAG,ex.getMessage().toString()); } finally { Log.i(TAG,"finally"); }

    Android debugging java question

  • Catch not working, why?
    C Crazy Joe Devola

    When the following code runs, an exception occurs at the setImageResource line. When I debug it, the right after that line the debugger jumps to the finally part, and then it goes into some java code in Runtimeinit.java to a method called private static class UncaughtHandler implements Thread.UncaughtExceptionHandler If I remark the finally section, then the exception is not caught by the catch part? Why isn't the catch part working? Isn't "catch (Exception ex)" supposed to catch any type of exception?

    try {
    ImageView imageV = (ImageView) findViewById(R.id.imageView);

    Log.i(TAG, "before setImageResource");
    imageV.setImageResource(R.drawable.merle);
    

    } catch (Exception ex) {
    Log.e(TAG,ex.getMessage().toString());
    } finally {
    Log.i(TAG,"finally");
    }

    Android debugging java question

  • Passing a class to a sprintf() and similar
    C Crazy Joe Devola

    Cool! thank you very much Richard. :thumbsup:

    C / C++ / MFC question c++

  • Passing a class to a sprintf() and similar
    C Crazy Joe Devola

    Thank you. Yes, char * works. However, when i use the CString class as in my example, no casting or conversion is required at all. What does the CString class have that my C1 does not? (obviously a lot :-) but specifically for what I am trying to do...)

    C / C++ / MFC question c++

  • Passing a class to a sprintf() and similar
    C Crazy Joe Devola

    I am trying to pass a class I wrote to sprintf(). Not the class itself actually, but a pointer to a string the class holds. With the VC++ CString class it works fine: sprintf(t, "%s", cst); But with my class, it either crashes the program or puts garbage into the t buffer: sprintf(t, "%s", c); Unless I use casting, and then it works ok: sprintf(t, "%s", (char *)c); What is my class missing? Some kind of an operator? Here is my code:

    class C1
    {
    public:
    C1()
    {
    sprintf(m_Data,"C1 class");
    }

    operator char *() { return m_Data; }

    private:
    char m_Data[100];
    };

    int main(int argc, char* argv[])
    {
    char t[1000]="";
    C1 c;
    CString cst("Test c string");

    sprintf(t, "%s", cst);
    sprintf(t, "%s", c);
    return 0;
    }

    C / C++ / MFC question c++
  • Login

  • Don't have an account? Register

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