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
_

_8086

@_8086
About
Posts
95
Topics
31
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • What's a device driver.
    _ _8086

    Thanks for your reply.

    Luc Pattyn wrote:

    without a specific driver your app might be able to interact with a peripheral, provided the peripheral uses a hardware interface that is supported by some general-purpose driver (e.g. for serial ports),

    So if we write to a port using CreateFile, will that be using Serial-Driver? The serial driver gets loaded when you connect some device in the port or it's running always? Also, does all hardware have the firmware on top for driver communication? Can any device without f/w be controlled by drivers alone? Let me get little more simpler. Assume I have motor running in a device. Now I need to write a driver that handles the RMP of it. I want to read/ control the RPM.. What are the sequence required? Lot more to ask actually. I will ask.

    ---------------------------- 286? WOWW!:-O

    Hardware & Devices help tutorial question career

  • What's a device driver.
    _ _8086

    Ok I googled the basics. Don't worry. But still I'm not getting it. That's the problem. Please see if I'm getting it right. First let me explain a situation without Device Driver: ANY device that wants to be controlled through PC has a firmware written on top of it(On the device side itself). The devices gives us the option to control through PORTS. like serial/USB. We can control these devices by knowing the f/w spec. If we know the firmware spec, we can send direct commands through a port application and communicate with device. For example, I create a RS232 application and ask the printer to do any job I want assuming I know it's firmware spec. Here no drivers are needed. With Driver: When do we need a driver? If we want any application to talk to the device. Right? So we get the firmware spec and implement all I/O in a common driver dll and we keep this port I/O implementation functions into the driver and the OS maps the application calls through this driver right? How does this work? Can I write my own device driver to control the mouse? Can you explain/give link to know the sequence? Please Don't give examples with driver frameworks. I want to know the underlying basics. Thanks in advance.

    ---------------------------- 286? WOWW!:-O

    Hardware & Devices help tutorial question career

  • Updating UI from thread
    _ _8086

    «_Superman_» wrote:

    The right way to do it is to post messages to the thread that owns the UI.

    You mean I should post the message straight to the control right?

    «_Superman_» wrote:

    For SetWindowText, this may not be a problem because the function does the same thing of sending the WM_SETTEXT message.

    You mean I can go ahead with myCtrol->SetWindowText()? Then which controls/APIs exactly make the problem?

    ---------------------------- 286? WOWW!:-O

    C / C++ / MFC tutorial design question announcement

  • Updating UI from thread
    _ _8086

    I have a worker thread for example, DWORD ThreadProc(void* pVal) { while() { pcEdit->SetWindowText("Status"); pcEdit2->SetWindowText("Status2"); } } Is it okay to update UI this way from the thread? Or how should I do? Anybody can explain in simple words? The above actually works fine. But mate says I shouldn't do it, but he doesn't say how to do it. :doh:

    ---------------------------- 286? WOWW!:-O

    C / C++ / MFC tutorial design question announcement

  • __declspec(dllimport)
    _ _8086

    Hi Randor, Just found this in MSDN : Using __declspec(dllimport) is optional on function declarations, but the compiler produces more efficient code if you use this keyword. However, you must use __declspec(dllimport) for the importing executable to access the DLL's public data symbols and objects. Note that the users of your DLL still need to link with an import library. Thanks for your reply.

    ---------------------------- 286? WOWW!:-O

    C / C++ / MFC question

  • char* as return type in dll
    _ _8086

    By the way, I'm keeping extern "C" char* _declspec(dllimport) Test(); in a .h file.

    ---------------------------- 286? WOWW!:-O

    C / C++ / MFC question

  • char* as return type in dll
    _ _8086

    error C2059: syntax error : '__declspec(dllimport)'

    ---------------------------- 286? WOWW!:-O

    C / C++ / MFC question

  • char* as return type in dll
    _ _8086

    char as return type works fine, extern "C" char _declspec(dllimport) Test(); _declspec(dllexport) char Test() { return 't'; } But why char* doesn't work here as the return type? extern "C" char* _declspec(dllimport) Test(); _declspec(dllexport) char* Test() { return "Test From DLL"; }

    ---------------------------- 286? WOWW!:-O

    C / C++ / MFC question

  • Doubt - C [modified]
    _ _8086

    Using internet means what? Even sending a file across n/w would mean "using internet".

    ---------------------------- 286? WOWW!:-O

    C / C++ / MFC help com design question

  • __declspec(dllimport)
    _ _8086

    Thanks for the Pointer Randor!

    ---------------------------- 286? WOWW!:-O

    C / C++ / MFC question

  • __declspec(dllimport)
    _ _8086

    To be true, I have never used dllimport in my code while using a module. What's the actual use of it? No matter we use it or not, we are able to access the exported symbol right?

    ---------------------------- 286? WOWW!:-O

    C / C++ / MFC question

  • Semaphore Max count.
    _ _8086

    Stuart Dootson wrote:

    Ummm - it'd create a new semaphore? Or are you creating a named semaphore and using the same name as previously (and if that's the case, the initial and maximum counts are ignored)?

    Yes I've been talking about named semaphores across multiple processes :). Also why it init, max counts should be ignored in this case?

    Stuart Dootson wrote:

    If you use WaitForSingleObject, it will return WAIT_OBJECT_0 if it acquires the semaphore or WAIT_TIMEOUT if the semaphore isn't available (unless you specify a timeout of INFINITE, in which case WaitForSingleObject will never return).

    Hmm okay now it's clear. I did have a wrong idea. For example, If the initial count = 3, maxcount =5. I thought 3 would get WAIT_OBJECT_ thing, the next 2 Would calls would "successfully-get-blocked" with the wait function. Any other calls after these wouldn't wait successfully. I thought this will also get through the wait function but with some error set in "last-error".

    ---------------------------- 286? WOWW!:-O

    C / C++ / MFC tutorial question

  • Semaphore Max count.
    _ _8086

    Hi Stuart, Let me continue my discussion now. Okay, now as you said, We'd require two threads to release the Semaphore without even acquiring it. Assume we are not doing it. Now the Semaphore variable counter would be 0. What should happen if a new process/thread tries to call CreateSemaphore now? Should I check for GetLastError()? So that I might get "Limit_reached" or something? Before putting the new handle into Wait function? Or I should pass the handle to the wait function straight and try to get check the value returned by it? Your answers have been awesome. Thanks a lot.

    ---------------------------- 286? WOWW!:-O

    C / C++ / MFC tutorial question

  • Semaphore Max count.
    _ _8086

    Stuart Dootson wrote:

    Does that make sense?

    Truly. Let me test this one now. Thanks dude.

    ---------------------------- 286? WOWW!:-O

    C / C++ / MFC tutorial question

  • Semaphore Max count.
    _ _8086

    Stuart Dootson wrote:

    So - in your case, initial count=3, max count=5, so the semaphore believes two of its 'slots' are filled when it is created. The first three waits on the semaphore succeed. Any waits after that will wait until ReleaseSemaphore is called and the thread can acquire the semaphore.

    Is it like at first the limit cap would be 3(As it assumes the other 2 to be filled already) but once we start to release semaphores, the cap would be extended to 5? For example: initially available slots: 3 ; Filled slots :2 ; SemVar=3 S1 Created. Successful wait-through. SemVar-- = 2 S2 Created. Successful wait-through. SemVar-- = 1 S3 Created. Successful wait-through. SemVar-- = 0, becomes 0 and becomes non-signled. S4 Cannot be created. Limit Reached. Keeps Waiting. S1 Released. SemVar++ = 1 (Now will it add 2 more counts here?) so that SemVar becomes 3 . Hence the final limit becomes 5. (2 already in use S2,S3 after we release S1). So as I just said, the currently available slots would be 3. Now S4 gets through. S5 gets through. S6 Gets through. So we have S2,S3,S4,S5,S6 in the ultimate list? Now the semaphore starts to operate on 0 to 5 limits. Rather than the 0 to 3 limit. Did I get you right?

    ---------------------------- 286? WOWW!:-O

    C / C++ / MFC tutorial question

  • Semaphore Max count.
    _ _8086

    I'm trying to figure out where exactly I would use the Max-Count value of a Semaphore. What's it's purpose? I have been thinking that when the number of processes trying to access the S-object reaches Initial-Count, Max-Count comes into picture. For example, If I had specified 3 as the initial count, 5 as the Max-Count and I'm invoking 3 processes to fill the initial-Count quota. These 3 successfully wait-through(pass-through) the wait-function. Now I execute the 4th process.. since I had mentioned 5 as Max-Count, I guessed it will allow only two more process to get into the block-wait.So It works, I'm able to put 4th and 5th processes into wait. (Though they don't pass the wait function, they just wait). I thought if I execute the 6th process, it would fail and I would get WAIT_FAILED result. But on the contrary, it keeps to wait along the 4th and 5th process. So I conclude my guess is wrong. Can anybody explain a bit on this max-count? Thanks.

    ---------------------------- 286? WOWW!:-O

    C / C++ / MFC tutorial question

  • Union
    _ _8086

    lol :-D

    ---------------------------- 286? WOWW!:-O

    C / C++ / MFC

  • Union
    _ _8086

    Such a small thing has got this much hidden! That's all about that crazy union :). Thanks mate.

    ---------------------------- 286? WOWW!:-O

    C / C++ / MFC

  • Union
    _ _8086

    Thanks.

    ---------------------------- 286? WOWW!:-O

    C / C++ / MFC

  • Union
    _ _8086

    union u { char ch[2]; int i; }; int main() { union u x={0,2}; cout<<x.ch<<"\n\n\n"; cout<<x.i<<endl; return 0; } Why does this print 512???:confused: What is this x={0,2}; exactly doing?

    ---------------------------- 286? WOWW!:-O

    C / C++ / MFC
  • Login

  • Don't have an account? Register

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