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
J

JonEngle

@JonEngle
About
Posts
30
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Want to melt those years away?
    J JonEngle

    Cool site, but I'm kinda questioning the accuracy. I put my birthday in (4/10/76) and it told me my next birthday would be April 11th, 2007.....

    The Lounge c++ csharp com architecture question

  • CComSafeArray
    J JonEngle

    Well, it's extremely uncommon to have a structure with uniform data types. Most structs are more like struct { int value; float fvalue; short somethingElse; etc., etc. } Now, for your case, I'd do one of two approaches. The big question is do you have to support scripting environments? Option 1) Using the interface Define the structure in IDL. This looks pretty much identical to you C structure definition. Define a method that returns these: For instance, in your IDL struct MY_STRUCT{ long a; long b; long c; }; //as a method on your COM object [propget, id(1)] HRESULT Item([in[ Index,[out,retval] struct MyDataType* blah); And implement from there. Option 2) Using a big safearray Create a safearray of variants (one for each structure), then each variant is a safearray of VT_I4. It's up to your client to know what the order of each value means, which means that this approach is fairly brittle.

    C / C++ / MFC question com data-structures

  • Detecting Loss of Client With CSockets
    J JonEngle

    He's right, but it doesn't work in all cases: client --- router ---- router -- server ^ break connection here If the network connection is broken between the client and server here, neither receives an error until they try to send data. Depending on how things are setup in your app, you might want to consider doing a ping message.

    C / C++ / MFC sysadmin question

  • CComSafeArray
    J JonEngle

    For question #1, maybe. It depends on how your data is stored. You can get a void * back from the safearray, then cast it to the type, the memcpy it: void *pData; SafeArrayAccessData(sa,&pData); memcpy((LPBYTE)pData,pMyByteArray,sizeof(BYTE)*numElements); or something similar. Question 2: This gets trickier. Different schools of thought: 1.) don't do that. Define the struct in IDL, define the interface to return those (say, maybe an Item property with an index). 2.) Someone has a gun to your head and says they'll kill you if you don't (only acceptable reason to do it this way): Create an array of variants. Each variant then in and of itself contains a safearray of bytes, which is one element in your array of structs. Version 2 of this, create a variant that is an array of bytes and memcpy the whole thing. If this is for something production, I highly suggest doing something different than blobbing it. It's much more extensible to have a collection interface that returns interfaces for each structure your defining: ActiveX Control | |----- property Item([in]long index, [out,retval] IStruct **ppIStruct) interface IStruct | |--- property name |--- property address etc etc, mapping a property value in IStruct to the value of your structure. If your using something like ATL, you might want to look at a tear-off interface for implementing this. Just a thought.

    C / C++ / MFC question com data-structures

  • CComSafeArray
    J JonEngle

    The variant type should tell you on the client (if your ActiveX control is putting them together correctly). For instance, the VT of the VARIANT would be VT_ARRAY | VT_I4 for longs, VT_ARRAY | VT_I2 for shorts, etc. It could be VT_ARRRAY | VT_VARIANT, which means that each element of the array is a variant itself, which agains means you'll have to test the VT.

    C / C++ / MFC question com data-structures

  • What do you call...
    J JonEngle

    Runtime Environment.

    The Lounge java csharp dotnet tutorial question

  • looking for good training material
    J JonEngle

    Hi, I'm looking for some good training material/coursework for C#. I've already hit the books some, but I'm looking for something I can use on a resume. Any suggestions would be welcome. BTW, I'm looking for something at an intermediate level, hopefully something good for a transition from C++/MFC to C#. Thanks!

    C# c++ csharp career

  • What drug actually cures a disease?
    J JonEngle

    You forgot tetanus and diphtheria. Of course, these are all vaccinations technically, ie profilactics instead of curing a disease once the individual has it. I remember reading something about smallpox serum, which is something they used for a short time before developing the vaccination. Basically, they would infect a pig with the disease, then take the antibodies from the pigs blood and give it to the sick person. If it didn't kill them (because of bad refining techniques), they would get better in a few days....apparently some research has been started down this path due to antibiotic resistance.

    The Lounge visual-studio com help tutorial question

  • String table in SQL database?
    J JonEngle

    I've just gone through the same problem in a large application. We've had some problems with the strings that have had to be located in the database, namely maintenance issues (it can be a bit of a pain to add new or change existing strings). For a good 90% of the strings, we put them in XML files that are loading into hash tables at run time. I prefer this approach, but either/or are a *lot* easier than resources! Just one more piece of advise, make sure however you put the strings together that you can change the order of the parameters in the string itself. We had some developers putting in printf-style formatting, and that was a nightmare for the translators.

    C / C++ / MFC database sqlite design question learning

  • Get IP address of computer (MFC/VC++)
    J JonEngle

    Look up GetIpAddrTable in MSDN.

    C / C++ / MFC c++ csharp visual-studio tutorial question

  • Defining global variables
    J JonEngle

    in cpp1.h -> extern int i; in cpp1.cpp -> int i; Then include cpp1.h where ever you need to use i

    C / C++ / MFC c++ tutorial question learning

  • IDataObject and Threading
    J JonEngle

    It sounds like you're not marshalling the interface across apartments.

    C / C++ / MFC help sysadmin linux

  • C++ using Crystal Reports
    J JonEngle

    In MSDN, under "Crystal Reports for Visual Studio .Net": When you are creating a C++ project to host Crystal reports on the Web or Windows, you should choose the Managed C++ Application template. Procedures that involve design view operations and automatic code generation to incorporate Crystal reports generally apply to Visual Basic and Visual C# projects only. You should use the Report Object Model, the Web Forms Viewer class description and the Windows Forms Viewer class description to incorporate Crystal reports in Managed C++ projects. It looks like the only portion of Crystal Reports they distribute with .Net is the .Net version, not the ActiveX controls or COM interfaces. So, is your C++ app a managed app?

    C / C++ / MFC csharp c++ com help tutorial

  • C++ using Crystal Reports
    J JonEngle

    Are you trying to run the report, display the report, or programmatically modify the report (you use different things for each)? By the way, you'll want to use their COM objects in C++, which aren't hard to use, and the VB and C# examples somewhat translate. By the way, which version of Crystal are you using?

    C / C++ / MFC csharp c++ com help tutorial

  • CString inside CMap
    J JonEngle

    you need to use CMap MyType;

    C / C++ / MFC help question

  • unhandle exception(8000ffff) while acceing ocx methods
    J JonEngle

    Sounds like a bug in the OCX, it might be expecting you to call some initialization function first. 0x8000ffff is E_CATASTROPHIC, which is pretty much a catch-all for "something bad happened". Is this your own ocx? If it is, you should be able to step through it in the debugger. If not, I'd still run it in the debugger and look for first-chance exceptions, that would be a good indication of something wrong in the 'Check' method.

    ATL / WTL / STL help com debugging

  • Word automation problem with C++
    J JonEngle

    Microsoft added this to Outlook after one of the slews of e-mail viruses. In older versions of outlook (98 and maybe 2000), this could be turned off, but I've never been able to find a way around it with outlook 2003. I ended up getting a 3rd party component for sending out e-mails. Sorry I don't have a better answer.

    COM help c++ com testing tools

  • LPSTR and LPBYTE passing to a dll
    J JonEngle

    I'd see if the seedToKey function their calling is exported, it seems like a safer function to use. Otherwise, I'd probably change this: BYTE seed[16] = {0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x8,0x9,0xa,0xb,0xc,0xd,0xe,0xf,0x00}; to char seed[] = {0x1,'\n'...,'\n',0xf,0x00}; You can also eliminate the cast that way.

    COM question c++ com hardware data-structures

  • LPSTR and LPBYTE passing to a dll
    J JonEngle

    This should work: BYTE seed[16] = {0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x8,0x9,0xa,0xb,0xc,0xd,0xe,0xf,0x00}; status = (*pSeedAndKeyFunc)((LPSTR)seed,key); it's probably looking for the null terminator on the string.

    COM question c++ com hardware data-structures

  • LPSTR and LPBYTE passing to a dll
    J JonEngle

    LPSTR = long pointer to string, ie char * LPBYTE = long pointer to byte, ie BYTE * -> ie unsigned char * Do you have the code snippet that's failing to build?

    COM question c++ com hardware data-structures
  • Login

  • Don't have an account? Register

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