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
C

ChemmieBro

@ChemmieBro
About
Posts
28
Topics
16
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Programmatically deleting old files with a C program
    C ChemmieBro

    That's about what I thought. (parsing the names) I'm stuck with standard C with no MFC support. This is an old, and very basic program, that I'm modifying. Looks like I'll just have to sort and use the Remove("filename.txt") function. Even with getting the file times, I'll still have to do some comparing/sorting. I'm actually thinking of just changing the file naming to adding a number to the end of the file. Since there are only 20 or 30 files (whatever I choose), I'll just increment those each time and delete when there gets to be 31 in the folder... it is crude, but easy. Thanks for the input. Thank goodness for programming advances since this was written...

    C / C++ / MFC question

  • Programmatically deleting old files with a C program
    C ChemmieBro

    I have an ancient program that creates logs named using the time when they are created. I need to delete the oldest files in the folder, only keeping the most recent 20, during runtime. Is there any way to do this in C? I can use Remove(filename), but then I have to go through each filename and compare dates. Seems like a hassle. Is there any function that returns the date of a file for comparison? Thanks.

    C / C++ / MFC question

  • Dividing the bits in a 16 bit short value
    C ChemmieBro

    Cool. That's what I was looking for originally. But the memcpy works. THANKS!

    C / C++ / MFC question data-structures

  • Dividing the bits in a 16 bit short value
    C ChemmieBro

    It looks like the memcpy might work. I didn't really want to go the route of using a Union. I was actually looking for a method to do this using bit shifting. Something like... unsigned char NewChar = MyStruct->Length << 8; which would put the 8 leftmost bits in Length into the NewChar, which you could put into Array[2]; but then, how do I get the other three bits from Length and merge them with the 5 bits from MyStruct->Value? I kind of know what I want to do it, but I don't know exactly how, what commands to use or what I'm doing.

    C / C++ / MFC question data-structures

  • Dividing the bits in a 16 bit short value
    C ChemmieBro

    I have a structure: typedef struct{ unsigned short Id : 8; unsigned short Name: 8; unsigned short Length: 11; unsigned short Value: 5; } MyStruct; I also have an array of bytes (unsigned char): I want to stick that structure into the first four bytes in the array. Array[0] = MyStruct->Id; Array[1] = MyStruct->Name; ...then what? How can I divide the last two values and put them into the [2] and [3] position in the byte array?

    C / C++ / MFC question data-structures

  • Type Cast from cli::array<unsigned char=""> to unsigned char*</unsigned>
    C ChemmieBro

    Hello! I am about 2 hours into looking at Managed Code, so I'm completely new to this. The problem I'm running into is casting a managed type to an unmanaged type. I need to cast a cli array of unsigned char into unsigned char *. Is there a Marshal:: function that can do this for me? Here's what's going on... MyFunction accepts (unsigned char *) MyFunction((unsigned char*)&pStructure->pCliArrayOfUChar) This obviously doesn't work because you can't cast from managed to unmanaged. (I just learned this!) Thanks for your help!!

    Managed C++/CLI help data-structures question

  • Is it okay to cast from int to unsigned char *?
    C ChemmieBro

    No. This is existing code and I was just curious if I was allowed to do that or not. I thought I could but couldn't find anything out there to confirm that it would work correctly. I will look up Unions, though, for future reference. Thank you.

    C / C++ / MFC data-structures question

  • Is it okay to cast from int to unsigned char *?
    C ChemmieBro

    I see that, now. Thank you. I just needed a quick answer and got it. I'm just re-using some code and they had done this same thing using an integer and a two shorts. I figured if it worked that way, it would work using an integer and four unsigned chars. Now I'll have to change the old stuff, too. Thanks again.

    C / C++ / MFC data-structures question

  • Is it okay to cast from int to unsigned char *?
    C ChemmieBro

    No, that's not a typo. The ByteArray is actually a different array type, but is still an array of unsigned char. If it is okay to get the IntegerValue into the unsigned char[4] then I'm okay. so... CharArray = new Unsigned Char [4]; CharArray = (unsigned char*)&IntegerValue ; That should still be fine. The 4 Unsigned Char bytes will then be populated with the bytes from the integer.

    C / C++ / MFC data-structures question

  • Is it okay to cast from int to unsigned char *?
    C ChemmieBro

    I have a 32bit int that I'm trying to stuff into an array of bytes. Is it okay to do this? CharArray = new unsigned char [4]; CharArray = (unsigned char *)&IntegerValue ByteArray[Length-4] = CharArray[3] ByteArray[Length-3] = CharArray[2] ByteArray[Length-2] = CharArray[1] ByteArray[Length-1] = CharArray[0]

    C / C++ / MFC data-structures question

  • VB6.0 - Common Dialog "ShowSave" method to get a Folder?
    C ChemmieBro

    Hello. I've already made my own form to use a GUI to search for a specific folder to save information to, but I was wondering if anyone knew a way to use the CommonDialog to do this? Currently, I can only get the CommonDialog to save to a specific file. What I want is for my user to be able to search and pick a specific folder. I just want to use the Common Dialog box to return the path to that folder. Is there any way to do this or should I just stick with my homemade method? Thank you!

    Visual Basic question

  • Form.Resize getting error when Minimize or Maximize is pressed
    C ChemmieBro

    I'm running VB6.0. I have a form that I need to be able to Maximize and Minimize, but I also have a Form.Resize procedure. During runtime, when I click the Minimize or Maximize button, I get an error (non-fatal) that says "A form can't be moved or sized while minimized or maximized". It's obviously trying to run my Form.Resize procedure. When I click Maximize, I want it to run the Form.Resize function because I do not want the form at its maximum width (full screen). When I click Minimize, I want it to be in the toolbar only, with no error. Here are the questions: 1. Is there a way to create a MaxWidth for the form, so when I click Maximize, it only goes to that width. 2. Is there a way to NOT run my Form.Resize when Minimize or Maximize is pressed or have it run without giving me the error? Thank you.

    Visual Basic help question

  • Add MCF support to an existing standard DLL
    C ChemmieBro

    So far I have found these two articles about adding MFC Support to an existing ATL DLL. They are both very similar. http://www.codeproject.com/com/COM_EXE_Server.asp#xx1175657xx[^] http://support.microsoft.com/kb/q173974/[^] Is there a way to add MFC support to an existing, non ATL, DLL?? I really only need just to add a simple dialog with a progress bar and a cancel button but my existing project is making this hard. Is it possible to use WTL somehow? I have never used it before. Thank you!

    C / C++ / MFC c++ com question

  • Adding MFC Support to a standard DLL Project
    C ChemmieBro

    So far I have found these two articles about adding MFC Support to an existing ATL DLL. They are both very similar. http://www.codeproject.com/com/COM_EXE_Server.asp#xx1175657xx[^] http://support.microsoft.com/kb/q173974/[^] Is there a way to add MFC support to an existing, non ATL, DLL?? I really only need just to add a simple dialog with a progress bar and a cancel button but my existing project is making this hard. Is it possible to use WTL somehow? I have never used it before. Thank you!

    ATL / WTL / STL c++ com question

  • Creating only one instance
    C ChemmieBro

    Hello, I'm very new to COM and just had a simple question. Does CoCreateInstance() check to see if there is another instance already in existance? I am currently using CoCreateInstance() to create my class object, but I only want to do it once. I want to do this: If (there is no instance) then (CoCreateInstance()) else (run code) Is this automatically done within CoCreateInstance or is there another way to check to see if an instance already exists? I want to avoid running CoCreateInstance() multiple times. Thank you.

    COM question com

  • Printing Array of Bytes to File
    C ChemmieBro

    I currently have an array of bytes and I want to print it to a file. When I open the filename and do the following statement: Print #FileName, ArrayOfBytes it prints a bunch of question marks and other characters that aren't the correct characters. When I run the debugger, the values within the individual elements of the array are all the correct decimal ascii values. ArrayOfBytes(1) = 50 It should be "P", which is what I want printed. ArrayOfBytes(2) = 88 It should be "X", which is what I want printed. How do I print this to a file but get the correct character values? Thank you.

    Visual Basic question data-structures debugging

  • Sending User Defined Types over COM Interface
    C ChemmieBro

    Hello, I'm pretty new to using COM and have run into a problem. I have a large structure, consisting of integers, user defined enumerations, several sub-structures and several dynamic arrays. How can I send this user defined type though COM? I'm trying to write my .idl file now to accept this structure... what needs to be done? My struct is much larger, but this small example should be enough to get me on the right track. //Example Struct: typedef struct { int index1; Image_Struct *Image_List; } My_Struct; //Image_Struct definition typedef struct { float pixel_x; float pixel_y; float pixel_z; } Image_Struct; Thank you!

    COM question com help tutorial

  • Problems with std::map
    C ChemmieBro

    Thank you so much. It was a pretty simple fix using the _bstr_t class instead of the BSTR. My inexperience with BSTR and _bstr_t got the best of me. I don't know why I chose BSTR in my map instead of _bstr_t. But everything is working fine now!

    C / C++ / MFC question ios com help

  • Problems with std::map
    C ChemmieBro

    Thanks for your help. I'm brand new to using BSTRs also. I do not have access to MFC here, so the CString is out. I will look into using some kind of wrapper around the BSTRs.

    C / C++ / MFC question ios com help

  • Problems with std::map
    C ChemmieBro

    This is my first experience with maps and I am having some troubles. I have developed a Logger that can do private logs depending on the client who calls the COM object. Based on the client's information, it needs to find the specific file to log to. Here is my code: //(header declarations) std::map m_FileList; std::map::iterator mFileListIterator; //(code) bool ClientHasCalledBefore; _bstr_t FileName; //name of the file coming in. //Look for FileName in map to see if it was called before. ClientHasCalledBefore = (!(m_FileList.find(FileName) == m_FileList.end())); // If it has called before, it logs to a clear file. // If not, it creates the file, then appends the logs. if (!ClientHasCalledBefore) { ofstream *ofstr = new ofstream(FileName, ios::out); m_FileList[FileName] = ofstr; *m_FileList[FileName] << "EntryToBeLogged"; m_FileList[FileName]->close(); } else { m_FileList[FileName]->open(FileName, ios::app); *m_FileList[FileName] << "EntryToBeLogged"; m_FileList[FileName]->close(); } Okay. This code leads me to my first question. When I enter a new file into the map, sometimes it does not enter properly and the next time the conditional is checked, the FileName is not found. It does this sometimes the first one to three times it runs through. After the first couple of times, everything works fine. Because I am opening the file clean, this overwrites the first couple of entries. Any suggestions so that my conditional finds the entry in the map the first time? //************** In my destructor, I have this code to add a footer to every file: for (m_FileListIterator = m_FileList.begin(); m_FileListIterator != m_FileList.end(); ++m_FileListIterator) { (m_FileListIterator->second)->open(FileListIterator->first, ios::app); *(m_FileListIterator->second) << "FooterToBeAdded"; (m_FileListIterator->second)->close(); } I think something is totally flawed with this. Sometimes it will append to a file I would have never created in my code, making a new file. Other times it will log the footer into the same file multiple times. It is almost as if it is not iterating. Again, this is my first experience with any of this. Any help is much appreciated. Thank you.

    C / C++ / MFC question ios com 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