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
K

Kuang Cao

@Kuang Cao
About
Posts
10
Topics
6
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • How to declare a struct with dynamic allocated array for COM with DLL?
    K Kuang Cao

    Hi, In my c++ code, I have a struct which has a dynamically allocated array. Now in c# code, I want to declare the same struct in a proper way so that I can call c++ native code from c#. If in C++ I have the following: struct A { int * arrInt; }; typedef struct A A_STRUCT; void func(A_STRUCT * ptrStruct); How would I declare the struct in c# and also how to define the function "prototype" when doing dllimport? Thanks a lot.

    C# c++ csharp com data-structures tutorial

  • Passing an array to a method?
    K Kuang Cao

    Hi, I have a question related to passing an array to a method. In C++, if I have an array Arr[] with 20 elements, and I want to pass the array to a method, but starts from the 10th element, then I would do the following: AMethod(Arr + 10); If I want to do the same thing in C#, what would be the proper way? Thanks a lot.

    C# question csharp c++ data-structures

  • How to create a "reference" to an object?
    K Kuang Cao

    Thanks.

    C# question csharp c++ tutorial

  • How to create a "reference" to an object?
    K Kuang Cao

    Hi, Suppose I have a function which takes in 4 objects as parameters like: methodA(classA obj1, classA obj2, classA obj3, classA obj4) and inside the method, a check will be performed and depending on the result, either the first three objects will be used, or the last three. The way I did this in C++ is basically by defining three pointers, and have those pointers point to either the first three objects or the last three depending on the check. And later those three pointers are used to access the data. But how can I achieve this in C#? Thanks a lot.

    C# question csharp c++ tutorial

  • Arrays in C# structs?
    K Kuang Cao

    But do I need to create a constructor inside the struct? If yes, I will have to list all those 53 parameters? Thanks.

    C# csharp c++ data-structures question

  • Arrays in C# structs?
    K Kuang Cao

    Hi, I am trying to convert c++ code into c# code, and I am having trouble with arrays in structs. The c++ struct looks like the following: typedef struct { int nAs; int As[8]; int nBs; int Bs[12]; int nCs; int Cs[30]; } AN_ENTRY; After quite a bit search, I figured out the definition can be changed to this: [StructLayout(LayoutKind.Sequential, Pack = 4)] public struct AnEntry { public int nAs; [MarshalAs(UnmanagedType.ByValArray, SizeConst=8)] public int[] As; public int nBs; [MarshalAs(UnmanagedType.ByValArray, SizeConst=12)] public int[] Bs; public int nCs; [MarshalAs(UnmanagedType.ByValArray, SizeConst=30)] public int[] Cs; } But how would I go around and initialize such a struct, I mean they are 53 integers that need to be passed in to initialize this? Can I do the following? AnEntry anEntry = new AnEntry(1, 1, 1, 1, ....., 1, 1); // 53 1's Do I have a define a constructor in the struct? If yes, the argument list of the constructor would be REALLY long. What if I need to create an array of AnEntry? Any suggestion or comment is highly appreciated. Thanks a lot.

    C# csharp c++ data-structures question

  • Question about time stamp info stored in the file?
    K Kuang Cao

    NTFS. And the CD used CDFS.

    C / C++ / MFC question

  • Question about time stamp info stored in the file?
    K Kuang Cao

    Hi, We need to acquire some research data in Europe with our software and then get the data sent over here (East coast US) for analysis. We tested to run the acquistion on a laptop with the time zone set to the place in Europe, but when burned/copied the data to a local-time-zone win2k machine, the time stamp got changed to the local time based on the difference of time zones. Since we want to keep the europe timestamp (or at lease being able to figure out that), I wonder how the time stamp info is stored in the file. Is there any existing function to simply get the local time of the file creation? I searched this forum and found the function SystemTimeToTzSpecificLocalTime(), but that would require us to tell the software that the data was acquired in a specific time zone, it would be the best if that time zone can be read out from the file directly. An interesting note, when we copied the burned file to a winnt machine, the time stamp was kept; when we copied the data from the winnt machine back to win2k, the time stamp was still kept, instead of getting swtiched based on local time zone. So somehow, the time zone info was lost when the file was copied to Winnt. Any explanations on this? Thanks a lot.

    C / C++ / MFC question

  • Visual C++: File or Folder?
    K Kuang Cao

    Sorry if I asked not good question. I am relatively new to Visual C++. I tried the CfileFind class. It seems that this the right one. But I still have some problems. The following is the code I tried. It works ok to find the specific file or directory. But when I tried to test whether this is a directory or not, it gives an "assertion failure". I have no idea how it happenes. Can you tell me what went wrong? Also, if possible, can you give me a little example (several lines) of how this may work? Thanks a lot. CFileFind finder; BOOL bWorking = finder.FindFile(filename); if(bWorking) { if(finder.IsDirectory()) { ...............

    C / C++ / MFC c++ java question

  • Visual C++: File or Folder?
    K Kuang Cao

    Hi, In Visual C++, if you create a file using CFile, is there any way to tell whether this file is a file or a folder? In Java, you can use "isDirectory()" to do this. Is there a similar way in Visual C++? Thanks. Or is there any other way to create a file? Any suggestion or comment is appreciated. Also, when using CFileDialog, all the folders and files will be displayed for you to select. Is there any way to only allow folders to show up? Thanks.

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

  • Don't have an account? Register

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