|
Oh, I thought the function should return 1 because it was successful in getting the interface. Am I missing something here? Does it mean that I am able to get the interface of the device who’s GUID I have assigned to USBIODS_GUID variable passing as parameter to the function?
Could you please explain to me, Mr Crow?
|
|
|
|
|
koumodaki wrote: Am I missing something here?
Yes. It will return nonzero if it completed without error, or it will return 0 if there are no more items (i.e., GetLastError() returns ERROR_NO_MORE_ITEMS ).
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
this is what I do:
HBITMAP hbm;
hbm = (HBITMAP)LoadImage(NULL, L"./image1.bmp", IMAGE_BITMAP, 0, 0,
LR_LOADFROMFILE|LR_CREATEDIBSECTION);
This works on .bmp files. But I wish to load .png files.
|
|
|
|
|
Have you considered using CImage ?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I'm trying to use DirectDraw inteface.
CImage is considerable. I tried to use it and got messed in the HDC stuff.
|
|
|
|
|
Hanan888 wrote: I tried to use it and got messed in the HDC stuff.
May be if you could show us the mess, someone may help you clean it up.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
|
Here is some mess:
First look then I'll detail:
CImage image
PAINTSTRUCT ps;
HDC hDC = BeginPaint (m_hWnd, &ps) ;
(line 4)
(line5) image.Load(L"./image.png");
image.Draw(hDC, (int) iter->second.m_pStaticData->m_UL.x, (int)
iter->second.m_pStaticData->m_UL.y);
EndPaint(m_hWnd, &ps);
This is 'below':
CImage image;
image.Load(L"./image.png");
pStatData->m_Texture = image;
The bottom line - no picture were painted. Painted all white.
(line 4) crashed.
(line 4) and (line 5) behave differently, can't understand why.
Perhaps there are some 'unwritten rules' for HDC stuff, I don't know them, I totally admit some sort of ignorance.
|
|
|
|
|
GDI has nothing to do with DirectDraw.
Check the return value from the CImage::Load() call....it's probably
failing since you're passing an invalid path.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hanan888 wrote: L"./image.png"
this should probably be _T(".\\image.png") .
forget it.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
I seem to recall that string literals can use either single slashes or double backslashes. I've not bothered to confirm this, however.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I made a test, you're right.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Hello Friends!
I've found an article of Amit Dey for creating Office Addins.
I am using office2003 and VC 6.0. I've created an ATL dll by following
his steps.I've registered this DLL but I can't see this addin when I want
to add this addin in outlook.Can anyone figure out what could be the
problem?
Thanks in Advance.
ritz1234
|
|
|
|
|
Do you see the entry for the addin in the registry.
Is the addin enabled from under the Tools menu. It might be disabled.
Check for wither of these two problems and could be that you come out of it.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Thanks for the greate response.
yes,the registry entry has been created.
Under Tools menu when I click COM-AddIns.. for adding this,
I see Addin-available dialogbox that is empty.I don't have anything to
select from here.
ritz1234
|
|
|
|
|
Hello,
I have big problem. About 1 week i search to find a way to convert a small C++ codes to VB 6.0. As a final i decided the best way is to make a dll from C codes to use this fubction in VB 6.0 . I searched a lot of articles but i couldn't succeed it because i don't know anything in C/C++. Somebody can help to me? Somebody can make a dll for me from this small code? Or can i convert these codes to VB 6.0 codes? If dll is possible i want to call "ComputeCrc" function from VB.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define CRC_A 1
#define CRC_B 2
#define BYTE unsigned char
unsigned short UpdateCrc(unsigned char ch, unsigned short *lpwCrc)
{
ch = (ch^(unsigned char)((*lpwCrc) & 0x00FF));
ch = (ch^(ch<<4));
*lpwCrc = (*lpwCrc >> 8)^((unsigned short)ch << 8)^((unsigned short)ch<<3)^((unsigned short)ch>>4);
return(*lpwCrc);
}
void ComputeCrc(int CRCType, char *Data, int Length,
BYTE *TransmitFirst, BYTE *TransmitSecond)
{
unsigned char chBlock;
unsigned short wCrc;
switch(CRCType) {
case CRC_A:
wCrc = 0x6363;
break;
case CRC_B:
wCrc = 0xFFFF;
break;
default:
return;
}
do {
chBlock = *Data++;
UpdateCrc(chBlock, &wCrc);
} while (--Length);
if (CRCType == CRC_B)
wCrc = ~wCrc;
*TransmitFirst = (BYTE) (wCrc & 0xFF);
*TransmitSecond = (BYTE) ((wCrc >> 8) & 0xFF);
return;
}
BYTE BuffCRC_A[10] = {0x12, 0x34};
BYTE BuffCRC_B[10] = {0x0A, 0x12, 0x34, 0x56};
unsigned short Crc;
BYTE First, Second;
FILE *OutFd;
int i;
int main(void)
{
printf("CRC-16 reference results ISO/IEC 14443-3\n");
printf("Crc-16 G(x) = x^16 + x^12 + x^5 + 1\n\n");
printf("CRC_A of [ ");
for(i=0; i<2; i++) printf("%02X ",BuffCRC_A[i]);
ComputeCrc(CRC_A, BuffCRC_A, 2, &First, &Second);
printf("] Transmitted: %02X then %02X.\n", First, Second);
printf("CRC_B of [ ");
for(i=0; i<4; i++) printf("%02X ",BuffCRC_B[i]);
ComputeCrc(CRC_B, BuffCRC_B, 4, &First, &Second);
printf("] Transmitted: %02X then %02X.\n", First, Second);
return(0);
}
</ctype.h></string.h></stdlib.h></stdio.h>
I think i don't need int main block when i use this code as a dll. So i must give BuffCRC_A and BuffCRC_B values from VB
Thanks
Best Regards
Murat
modified on Thursday, March 20, 2008 8:48 AM
|
|
|
|
|
First of all, please use <pre> tags to surround (i.e. properly format) code snippets.
Of course both methods you proposed (wrap code in a DLL or convert it into VB6 one) are feasible and both methods require a bit of C programming knowledge: I think it is the opportunity time to start learning this language.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
I modified my first post according to your advice. Thanks
In fact i want to learn C/C++ very much but i don't have time now for this. I develop a project for my company and i have to finish this project in 1 week. So if you can help to me i will be so glad. This is really so important for me...
Best Regards
Murat
|
|
|
|
|
DLL definition file (CRCDLL.def)
LIBRARY "CRCDLL"
EXPORTS ComputeCrc
DLL header file (CRCDLL.h)
void __stdcall ComputeCrc(int CRCType, BYTE *Data, int Length, BYTE *TransmitFirst, BYTE *TransmitSecond);
DLL source file (CRCDLL.cpp)
#include "stdafx.h"
#include "CRCDLL.h"
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
#define CRC_A 1
#define CRC_B 2
unsigned short UpdateCrc(unsigned char ch, unsigned short *lpwCrc)
{
ch = (ch^(unsigned char)((*lpwCrc) & 0x00FF));
ch = (ch^(ch<<4));
*lpwCrc = (*lpwCrc >> 8)^((unsigned short)ch << 8)^((unsigned short)ch<<3)^((unsigned short)ch>>4);
return(*lpwCrc);
}
void __stdcall ComputeCrc(int CRCType, BYTE *Data, int Length, BYTE *TransmitFirst, BYTE *TransmitSecond)
{
unsigned char chBlock;
unsigned short wCrc;
switch(CRCType)
{
case CRC_A:
wCrc = 0x6363;
break;
case CRC_B:
wCrc = 0xFFFF;
break;
default:
return;
}
do
{
chBlock = *Data++;
UpdateCrc(chBlock, &wCrc);
} while (--Length);
if (CRCType == CRC_B)
wCrc = ~wCrc;
*TransmitFirst = (BYTE) (wCrc & 0xFF);
*TransmitSecond = (BYTE) ((wCrc >> 8) & 0xFF);
return;
}
Visual Basic sample code (actually it is VBA, I haven't VB6 here).
Private Declare Sub ComputeCrc Lib "CRCDLL.dll" _
(ByVal CRCType As Long, Data As Byte, ByVal Length As Long, TrnasmitFirst As Byte, TransmitSecond As Byte)
Private Sub CommandButton1_Click()
Dim Data(2) As Byte
Dim TransmitFirst As Byte
Dim TransmitSecond As Byte
Data(0) = &H12
Data(1) = &H34
Call ComputeCrc(1, Data(0), 2, TransmitFirst, TransmitSecond)
End Sub
Hope that helps.
Please note, VB code assumes the DLL is in the same folder of the VB6 executable, change it according to your needs.
BTW an oldie goldie: http://support.microsoft.com/?scid=kb%3Ben-us%3B106553&x=12&y=15[^]
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
modified on Thursday, March 20, 2008 11:35 AM
|
|
|
|
|
Muratss wrote: I think i don't need int main block when i use this code as a dll.
True, you'll use DllMain() instead.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
DavidCrow,
You can show me a starting point? I thought i can use "Win32 Dynamic Link-Library" to get this Dll. please show me a starting point and i will try to other things.
|
|
|
|
|
Muratss wrote: I thought i can use "Win32 Dynamic Link-Library" to get this Dll. please show me a starting point...
That's where I'd start.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I read a article and i started. I started with crating "Win32 Dynamic-Link Library" project.
According to article i need 3 files which have extensions as .cpp,.def and .h
I prepared these files
Here my .h file :
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
void __stdcall ComputeCrc(int CRCType, char *Data, int Length,
BYTE *TransmitFirst, BYTE *TransmitSecond)
</ctype.h></string.h></stdlib.h></stdio.h>
This is my .cpp file :
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define CRC_A 1
#define CRC_B 2
#define BYTE unsigned char
unsigned short__stdcall UpdateCrc(unsigned char ch, unsigned short *lpwCrc)
</ctype.h></string.h></stdlib.h></stdio.h>
and this is my .def file : (My project name is Calculate_CRC)
LIBRARY Calculate_CRC
DESCRIPTION 'A C++ dll that can be called from VB'
EXPORTS
ComputeCrc @1
I have an error where UpdateCrc function is. I hope this is a good starting for me..I wait your help...
PS: I need *TransmitFirst and *TransmitSecond values in my project
Best Regards
|
|
|
|
|
Muratss wrote: I started with crating "Win32 Dynamic-Link Library" project.
Which should have given you the neccesary files to start with. For example, I created a project named ComputeCRC, and I have the following files to work with:
ComputeCRC.cpp
ComputeCRC.h
StdAfx.cpp (you'll likely not change this file)
StdAfx.h Start this way, rather than trying to mold your existing EXE code into a DLL.
Muratss wrote: I have an error where UpdateCrc function is.
Likely because of void__stdcall .
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|